Files
wehub-resource-sync e768098d0e
Flake8 Lint / flake8 (push) Waiting to run
Spell check CI / Spell_Check (push) Waiting to run
tools_continuous_delivery / Private PyPI non-main branch release (push) Has been skipped
tools_continuous_delivery / Private PyPI main branch release (push) Failing after 2m42s
Publish Promptflow Doc / Build (push) Has been cancelled
Publish Promptflow Doc / Deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:39:52 +08:00
..

Named Entity Recognition

A flow that perform named entity recognition task.

Named Entity Recognition (NER) is a Natural Language Processing (NLP) task. It involves identifying and classifying named entities (such as people, organizations, locations, date expressions, percentages, etc.) in a given text. This is a crucial aspect of NLP as it helps to understand the context and extract key information from the text.

This sample flow performs named entity recognition task using ChatGPT/GPT4 and prompts.

Tools used in this flow

  • python tool
  • built-in llm tool

Connections used in this flow:

  • azure_open_ai connection

Prerequisites

Install promptflow sdk and other dependencies:

pip install -r requirements.txt

Setup connection

Prepare your Azure OpenAI resource follow this instruction and get your api_key if you don't have one.

Note in this example, we are using chat api, please use gpt-35-turbo or gpt-4 model deployment.

Create connection if you haven't done that. Ensure you have put your azure OpenAI endpoint key in azure_openai.yml file.

# Override keys with --set to avoid yaml file changes
pf connection create -f ../../../connections/azure_openai.yml --set api_key=<your_api_key> api_base=<your_api_base>

Ensure you have created open_ai_connection connection.

pf connection show -n open_ai_connection

Run flow

Run with single line input

# test with default input value in flow.dag.yaml
pf flow test --flow .
# test with specific input
pf flow test --flow . --inputs text='The phone number (321) 654-0987 is no longer in service' entity_type='phone number'

run with multiple lines data

  • create run
pf run create --flow . --data ./data.jsonl --column-mapping entity_type='${data.entity_type}' text='${data.text}' --stream

You can also skip providing column-mapping if provided data has same column name as the flow. Reference here for default behavior when column-mapping not provided in CLI.