Skip to main content

Text Analysis Solutions

Exam weight: 10–15%

Overview

AI-103 tests text and speech analysis in the context of Foundry Tools — Azure AI Language, Azure Translator, and Azure AI Speech accessed through the Foundry ecosystem. The exam also covers using LLM prompting as an alternative to dedicated service calls for some text analysis tasks.

Key Concepts

Language Analysis

TechniqueFoundry Tool / ApproachWhat it returns
Entity extractionAzure AI Language or LLM promptNamed entities with categories
Topic extractionLLM prompt with structured outputTopics as JSON
SummarizationAzure AI Language or LLMAbstractive or extractive summary
Sentiment / toneAzure AI Language or LLMpositive / negative / neutral + confidence
Safety / harmful content detectionAzure AI Content SafetyCategory + severity scores
PII detectionAzure AI LanguagePII entities with optional redaction
Text translationAzure Translator in Foundry ToolsTranslated text

LLM-based Text Analysis (structured JSON output)

Using generative models for text analysis is increasingly common in AI-103 scenarios:

from azure.ai.inference import ChatCompletionsClient
from azure.ai.inference.models import SystemMessage, UserMessage
from azure.core.credentials import AzureKeyCredential
import json

client = ChatCompletionsClient(endpoint="<endpoint>", credential=AzureKeyCredential("<key>"))

response = client.complete(
model="gpt-4o",
messages=[
SystemMessage("""Extract the following from the user's text and return as JSON:
- entities: list of {text, type} where type is Person, Organization, or Location
- sentiment: "positive", "negative", or "neutral"
- summary: one sentence summary
Return only valid JSON, no other text."""),
UserMessage("Microsoft announced new AI features at their Seattle headquarters yesterday.")
],
response_format={"type": "json_object"},
)

result = json.loads(response.choices[0].message.content)
print(result)

Speech Solutions

CapabilityImplementation
Speech-to-text (STT)Azure AI Speech in Foundry Tools
Text-to-speech (TTS)Azure AI Speech in Foundry Tools — neural voices
Custom speechFine-tuned STT model for domain vocabulary
Agent speech modalityIntegrate STT/TTS into an agent for voice interaction
Audio-to-text with LLM reasoningSend audio to a multimodal model (GPT-4o audio)
Speech translationAzure AI Speech real-time translation
import azure.cognitiveservices.speech as speechsdk

speech_config = speechsdk.SpeechConfig(subscription="<key>", region="<region>")
speech_config.speech_synthesis_voice_name = "en-US-JennyNeural"

# Text to Speech
synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config)
synthesizer.speak_text_async("Hello, I am an AI assistant.").get()

# Speech to Text
recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config)
result = recognizer.recognize_once()
print(result.text)

When to Use LLM vs. Dedicated Service

ScenarioRecommendation
Simple, structured extraction at scaleDedicated Azure AI Language service (faster, cheaper)
Complex, domain-specific extractionLLM with structured output prompt
Translation of standard languagesAzure Translator (accurate, cost-effective)
Translation with context / tone preservationLLM-powered translation flow
High-volume speech transcriptionAzure AI Speech (optimized)
Voice interaction in an agentAzure AI Speech integrated with Foundry Agent

Study Resources