Text Generation
Transformers
Safetensors
Korean
English
Japanese
qwen3
conversational
text-generation-inference
Instructions to use jaeyong2/Dynamic_NER with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jaeyong2/Dynamic_NER with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jaeyong2/Dynamic_NER") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("jaeyong2/Dynamic_NER") model = AutoModelForCausalLM.from_pretrained("jaeyong2/Dynamic_NER") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jaeyong2/Dynamic_NER with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jaeyong2/Dynamic_NER" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jaeyong2/Dynamic_NER", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/jaeyong2/Dynamic_NER
- SGLang
How to use jaeyong2/Dynamic_NER with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "jaeyong2/Dynamic_NER" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jaeyong2/Dynamic_NER", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "jaeyong2/Dynamic_NER" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jaeyong2/Dynamic_NER", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use jaeyong2/Dynamic_NER with Docker Model Runner:
docker model run hf.co/jaeyong2/Dynamic_NER
Update README.md
Browse files
README.md
CHANGED
|
@@ -56,4 +56,60 @@ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
|
| 56 |
<entities>
|
| 57 |
[{'text': 'Tim', 'type': 'PERSON'}, {'text': 'mom', 'type': 'PERSON'}, {'text': 'Sue', 'type': 'PERSON'}, {'text': 'park', 'type': 'LOCATION'}, {'text': 'fountain', 'type': 'LOCATION'}, {'text': 'fish', 'type': 'ANIMAL'}]
|
| 58 |
</entities>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
```
|
|
|
|
| 56 |
<entities>
|
| 57 |
[{'text': 'Tim', 'type': 'PERSON'}, {'text': 'mom', 'type': 'PERSON'}, {'text': 'Sue', 'type': 'PERSON'}, {'text': 'park', 'type': 'LOCATION'}, {'text': 'fountain', 'type': 'LOCATION'}, {'text': 'fish', 'type': 'ANIMAL'}]
|
| 58 |
</entities>
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
### examlpe (ko)
|
| 62 |
+
```
|
| 63 |
+
system = """
|
| 64 |
+
You are an AI that dynamically performs Named Entity Recognition (NER).
|
| 65 |
+
You receive a sentence and a list of entity types the user wants to extract, and then identify all entities of those types within the sentence.
|
| 66 |
+
If you cannot find any suitable entities within the sentence, return an empty list.
|
| 67 |
+
"""
|
| 68 |
+
|
| 69 |
+
text = """
|
| 70 |
+
μμ§μ΄λ μ§λμ£Ό ν μμΌμ μ€ννλ νλ¨μ κ°μ΄μ.
|
| 71 |
+
κ·Έλ€μ μ ν μ€ν μ΄μμ μλ‘ λμ¨ μμ΄ν° 16μ ꡬ경νκ³ , μΉ΄ν λ
Έν°λμμ λλμ λ¨Ήμμ΄μ.
|
| 72 |
+
κ·Έλ μ λ
μ λ°©νμλ
λ¨ μ½μνΈ μ€ν© μνλ₯Ό λ΄€μ΄μ. μ λ§ μ λ¬μ£ !
|
| 73 |
+
""".strip()
|
| 74 |
+
|
| 75 |
+
named_entity = """
|
| 76 |
+
[
|
| 77 |
+
{"type": "PERSON", "description": "μ¬λ μ΄λ¦"},
|
| 78 |
+
{"type": "LOCATION", "description": "μ§λͺ
λλ μ₯μ"},
|
| 79 |
+
{"type": "ORGANIZATION", "description": "μ‘°μ§, νμ¬, λ¨μ²΄"},
|
| 80 |
+
{"type": "PRODUCT", "description": "μ νλͺ
"},
|
| 81 |
+
{"type": "WORK_OF_ART", "description": "μμ μν, μν, μ±
, λ
Έλ λ±"},
|
| 82 |
+
{"type": "DATE", "description": "λ μ§, μμΌ, μμ "}
|
| 83 |
+
]
|
| 84 |
+
""".strip()
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
user = f"<sentence>\n{text}\n</sentence>\n\n<entity_list>\n{named_entity}\n</entity_list>\n\n"
|
| 88 |
+
chat = [{"role":"system", "content":system}, {"role":"user", "content":user}]
|
| 89 |
+
chat_text = tokenizer.apply_chat_template(
|
| 90 |
+
chat,
|
| 91 |
+
enable_thinking=False,
|
| 92 |
+
add_generation_prompt=True,
|
| 93 |
+
tokenize=False
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
model_inputs = tokenizer([chat_text], return_tensors="pt").to(model.device)
|
| 97 |
+
|
| 98 |
+
generated_ids = model.generate(
|
| 99 |
+
**model_inputs,
|
| 100 |
+
max_new_tokens=512
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
generated_ids = [
|
| 104 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 105 |
+
]
|
| 106 |
+
|
| 107 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
### result (ko)
|
| 111 |
+
```
|
| 112 |
+
<entities>
|
| 113 |
+
[{'text': 'μμ§μ΄', 'type': 'PERSON'}, {'text': 'μ€ννλ νλ¨', 'type': 'LOCATION'}, {'text': 'μμ΄ν° 16', 'type': 'PRODUCT'}, {'text': 'λ°©νμλ
λ¨', 'type': 'ORGANIZATION'}, {'text': 'μ½μνΈ μ€ν© μν', 'type': 'WORK_OF_ART'}, {'text': 'ν μμΌ', 'type': 'DATE'}, {'text': 'μΉ΄ν λ
Έν°λ', 'type': 'LOCATION'}]
|
| 114 |
+
</entities>
|
| 115 |
```
|