- Blog
- Inference Applications
Inference Applications
5.1 Sentiment Classification of Product Review Texts
Using a desk lamp review as an example, we classify the sentiment of the review by writing prompts.Prompt Example:"What is the sentiment of this product review?"Output Result:The sentiment of this product review is positive.(Summary of the review: The desk lamp isn't perfect, but the customer is satisfied and praises the company for caring about customers and products.)
5.2 Text Sentiment Classification
Use prompts to determine if the review author is expressing anger (or other emotions).Application Scenario:Identify customer feedback requiring priority handling (e.g., angry emotions) and direct them to customer support channels for resolution.Suggested Exercise:Try modifying the prompt (e.g., asking "Does the customer show happiness?" or "Are there any missing parts?") to observe different inference results.
5.3 Text Information Extraction
Extract structured information from text (e.g., product names, brands, sentiments, etc.).
Single-Field Extraction Example
Prompt:"Identify the following items: the purchased product and the company name that manufactures it. Format the response as a JSON object."Output:
json
{ "product": "desk lamp", "brand": "Luminar" }
Multi-Field Joint Extraction
Prompt:"Identify the following categories: sentiment, whether anger is expressed, purchased product, manufacturer. Format the anger value as a boolean and output as JSON."Output:
json
{ "sentiment": "positive", "angry": false, "product": "desk lamp with extra storage", "manufacturer": "Luminar" }
Advantage: Extract multiple fields with a single prompt, reducing API call frequency.
5.4 Text Theme Inference
Given a long text, extract its core themes.Example Scenario:Analyze a fictional article about "government workers' feelings toward their institutions" (involving NASA satisfaction surveys).Prompt:"Identify five themes discussed in the following text. Format each item as one or two words, separated by commas."Example Output:government survey, job satisfaction, NASA, employee feedback, institutional evaluation
5.5 Text Information Analysis
Determine whether a text covers specific themes from a predefined list (zero-shot learning).Theme List:NASA, local government, engineering, employee satisfaction, federal governmentPrompt:"Determine whether each theme in the list appears in the text. Output a list of 0s or 1s for each theme."Output Logic:
- NASA: 1
- Local government: 0
- Engineering: 0
- Employee satisfaction: 1
- Federal government: 1Application Value: Quickly index article themes to assist with content classification and analysis.
Note: The above content is refined from the original article's core knowledge points, excluding image references, repetitive guidance, and irrelevant context.
Inference Applications