Key phrase extraction and named entity recognition (NER) sit at the front of almost every text-pipeline question because they answer two distinct problems with overlapping inputs. Key phrase extraction returns the salient noun phrases of a document, useful for tagging, topic clustering, search-result enrichment, and feeding downstream RAG indexers. Named entity recognition returns typed spans (Person, Organization, Location, DateTime, Quantity, IP address, URL, Email, and many more) with confidence scores and offsets, which is what you want when the downstream system needs structured fields rather than a bag of phrases. The two features share the same Language resource, the same authentication, and the same SDK package (azure-ai-language-text), but they are billed and rate-limited as separate text records.
The Language resource exposes both skills through the TextAnalysisClient in the SDK and through the /language/:analyze-text REST endpoint. The endpoint accepts a kind field that names the skill (KeyPhraseExtraction, EntityRecognition, PiiEntityRecognition, LanguageDetection, SentimentAnalysis) so a single deployment hosts every prebuilt task without per-skill provisioning. Asynchronous variants of each kind exist for batch processing, and the analyze API can chain multiple skills on the same input through the analyze-text/jobs route, which billing meters as one document per skill.
NER ships in two flavors. The generalized NER model returns the broad type catalog and is the right default for most production workloads. The Personally Identifiable Information variant adds finer subtypes (CreditCardNumber, ABARoutingNumber, EUDriversLicenseNumber, NationalID, and so on) and includes a redaction string in the response. Both variants accept a piiCategories or categories filter so you only pay attention to the entity classes you care about. If you need entity types that are not in the generalized catalog (for example, medication name, contract clause, or part number), the project-based custom NER path replaces the prebuilt model with one trained on your labeled examples and deploys to the same /language/:analyze-text endpoint under a project name and deployment name.
Key phrase extraction is purely extractive: it returns substrings of the input. It does not paraphrase, deduplicate across documents, or rank by global corpus statistics. Because of that, two operational realities follow. First, an input that is already a list of nouns will return almost every word as a key phrase, so feed it whole sentences. Second, the order in the response is not a ranking; if you need ranked phrases for a topic feed, post-process with TF-IDF or send the candidates through an embedding-based scorer.
The Language service caps each request at 1,000 documents and 125,000 characters per request. Each document has a 5,120 character ceiling for synchronous analysis. Anything longer must be chunked before submission, and the chunk boundary should sit on a sentence break so entity spans are not truncated mid-token. The API returns offsets in UTF-16 code units by default, which means surrogate-pair characters (emoji, some CJK code points) count as two units; pass stringIndexType=Utf8 or Utf32CodePoint when your downstream consumer needs different semantics.
from azure.ai.language.text import TextAnalysisClient
from azure.identity import DefaultAzureCredential
client = TextAnalysisClient(
endpoint="https://contoso-lang.cognitiveservices.azure.com/",
credential=DefaultAzureCredential(),
)
documents = [
{"id": "1", "language": "en",
"text": "Contoso shipped the new transformer cooling unit from Munich on the 14th, paid via card ending 4242."},
{"id": "2", "language": "en",
"text": "Customer escalated the firmware bug to the EMEA support lead at adelev@contoso.com."},
]
phrases = client.extract_key_phrases(documents=documents)
entities = client.recognize_entities(documents=documents, categories=["Organization", "Location", "DateTime", "Email"])
for doc in phrases:
if not doc.is_error:
print(doc.id, doc.key_phrases)
for doc in entities:
if not doc.is_error:
for ent in doc.entities:
print(doc.id, ent.text, ent.category, ent.subcategory, ent.confidence_score, ent.offset, ent.length)
The same flow against the asynchronous job endpoint chains skills so a single request returns key phrases, entities, and PII redaction together. Async jobs are the only path that returns the tasks.items[*].results array per skill, and the job ID is required to fetch results.
curl -X POST "https://contoso-lang.cognitiveservices.azure.com/language/analyze-text/jobs?api-version=2024-11-15-preview" \
-H "Authorization: Bearer $(az account get-access-token --resource https://cognitiveservices.azure.com/ --query accessToken -o tsv)" \
-H "Content-Type: application/json" \
-d '{
"displayName": "ingest-pipeline-batch",
"analysisInput": { "documents": [
{"id":"1","language":"en","text":"Contoso shipped..."}
]},
"tasks": [
{"kind":"KeyPhraseExtraction","taskName":"phrases"},
{"kind":"EntityRecognition","taskName":"entities","parameters":{"modelVersion":"latest"}},
{"kind":"PiiEntityRecognition","taskName":"pii","parameters":{"piiCategories":["Person","Email","CreditCardNumber"]}}
]}'
💡 Exam Trap: Key phrase extraction and entity recognition share the same Language resource, but you cannot call them through the Translator endpoint or the Foundry Models inference endpoint. A stem that describes "use the Translator resource to extract entities" is a wrong-service trap and the right answer routes the call to the Language resource on
cognitiveservices.azure.com/language/....
💡 Exam Trap: The Language API returns text offsets in UTF-16 code units by default. If a question describes a downstream consumer that mishandles offsets for emoji or 4-byte CJK characters, the fix is
stringIndexType=Utf8orUtf32CodePoint, not a re-implementation of the highlight logic in client code.
📊 Limit: A single synchronous
analyze-textrequest accepts up to 1,000 documents, 125,000 characters total, and 5,120 characters per document. Async jobs lift the per-document ceiling to 125,000 characters but keep the 1,000-document total.
⚠️ Anti-Pattern: Calling key phrase extraction on a list of titles or already-extracted keywords and treating the response as a ranked summary. Output order is not a ranking, and the skill returns almost every token in short inputs; re-score with embeddings if you need ranked tags.
🎯 Scenario: A support analytics pipeline streams 8 KB customer-email bodies into a function. The function must redact credit card numbers, tag the message with the top topics, and store the unredacted version in a sealed store. Use one async
analyze-text/jobscall chainingPiiEntityRecognitionfor redaction,EntityRecognitionfor typed offsets, andKeyPhraseExtractionfor tags; chunk on sentence boundaries before submission because 8 KB exceeds the 5,120-character synchronous cap.
Decision Anchor: Choose the generalized NER model when the entity catalog (Person, Organization, Location, DateTime, Quantity, IP, URL, Email) covers the schema. Choose Custom NER (a project under the Language resource) when the schema includes domain types that the generalized catalog does not list, you can supply at least 50 labeled documents per type, and you accept the authoring and deployment overhead.
Implement custom speech solutions with Azure Speech in Foundry Tools
Custom Speech is the project surface that adapts the base speech-to-text model to a target acoustic environment, vocabulary, or speaking style. It lives in the Speech Studio under the same Speech resource that serves real-time, batch, and fast transcription. A Custom Speech project carries three artifact types: training data (audio + transcript pairs, plain-text language data, pronunciation data, or output-format data), a custom model trained from a base model version, and a custom endpoint that pins the deployed model to a stable URL.
The minimum useful training set depends on the goal. Pure language adaptation (rare domain words, product names, jargon) succeeds with as little as 5 MB of related text and no audio. Acoustic adaptation (specific microphone, far-field, accent) wants at least a few hours of representative audio with verbatim transcripts. Pronunciation files map written tokens to phonetic spellings in SAPI format, which is the right answer when the engine consistently mishears a brand name despite ample language data.
az cognitiveservices account create \
--name contoso-speech \
--resource-group rg-nlp \
--kind SpeechServices \
--sku S0 \
--location swedencentral
# Upload a language dataset
curl -X POST "https://swedencentral.api.cognitive.microsoft.com/speechtotext/v3.2/datasets" \
-H "Ocp-Apim-Subscription-Key: $SPEECH_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind":"Language",
"contentUrl":"https://stcontoso.blob.core.windows.net/speech/lang.txt?...sas...",
"locale":"en-US",
"displayName":"contoso-product-vocab"
}'
After training completes, evaluate with a held-out test set; the report returns Word Error Rate (WER) and token error rate against the base model. Deploy by creating a custom endpoint, which mints a stable model ID that callers reach by passing EndpointId on the SpeechConfig in the SDK or by appending ?cid=<endpoint-id> to the REST URI. Custom endpoints can be allocated as dedicated for predictable throughput or non-dedicated for cost-sharing across tenants.
Add question-and-answer pairs and import sources for question answering
Custom question answering, the Foundry-era successor to QnA Maker, is a project under the Language resource that maps user questions to authored answers. The project ingests sources of three shapes: a URL to a public web page (the importer extracts FAQ-shaped sections), an uploaded file (PDF, DOCX, TSV, or Excel of question/answer rows), or manually entered pairs. Each source becomes a list of qnaPairs with an answer, a list of alternate questions, optional metadata, and an optional follow-up prompt list for multi-turn flows.
# Import a FAQ URL into an existing project
curl -X PATCH "https://contoso-lang.cognitiveservices.azure.com/language/query-knowledgebases/projects/support-kb/sources?api-version=2023-04-01" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '[ {
"op":"add",
"value": {
"displayName":"product-faq",
"source":"https://contoso.com/support/faq",
"sourceUri":"https://contoso.com/support/faq",
"sourceKind":"url",
"contentStructureKind":"unstructured"
}
}]'
The choice between unstructured and semiStructured source kinds drives ingestion behavior. Semi-structured mode treats the input as a literal Q/A table and the importer trusts the row boundaries. Unstructured mode runs the page through a layout extractor that infers Q/A pairs, headers, and section anchors; this is the right choice for prose-heavy FAQs but produces noise on tables of figures.
💡 Exam Trap: A custom question answering project is not the same as a CLU project. CLU resolves intent and entities from free-form utterances and routes the call. Custom question answering returns a stored answer by similarity. Both can coexist behind an Orchestration Workflow project, which routes the user input to whichever child gets the higher confidence.
