Text Generation
Transformers
Safetensors
English
phi3
nlp
ner
conversational
custom_code
text-generation-inference
Instructions to use LIBRAAITECH/Phi-3.5-mini-instruct-NER with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LIBRAAITECH/Phi-3.5-mini-instruct-NER with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="LIBRAAITECH/Phi-3.5-mini-instruct-NER", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("LIBRAAITECH/Phi-3.5-mini-instruct-NER", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("LIBRAAITECH/Phi-3.5-mini-instruct-NER", trust_remote_code=True) 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
- vLLM
How to use LIBRAAITECH/Phi-3.5-mini-instruct-NER with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "LIBRAAITECH/Phi-3.5-mini-instruct-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": "LIBRAAITECH/Phi-3.5-mini-instruct-NER", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/LIBRAAITECH/Phi-3.5-mini-instruct-NER
- SGLang
How to use LIBRAAITECH/Phi-3.5-mini-instruct-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 "LIBRAAITECH/Phi-3.5-mini-instruct-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": "LIBRAAITECH/Phi-3.5-mini-instruct-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 "LIBRAAITECH/Phi-3.5-mini-instruct-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": "LIBRAAITECH/Phi-3.5-mini-instruct-NER", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use LIBRAAITECH/Phi-3.5-mini-instruct-NER with Docker Model Runner:
docker model run hf.co/LIBRAAITECH/Phi-3.5-mini-instruct-NER
Geo-Temporal Entity Recognition Model
This model is a finetuned version of Phi-3.5-mini-instruct. It detects the location and date entities in a query. It also maps the location entities to the corresponding set of countries, and the date entities to either a start and end date, or the corresponding months. Additionally, it generates the query that is cleaned from the date entities and the location entities that are countries.
The prompt on which the model was finetuned is the following:
from datetime import date
today = date.today()
schema = """
country: Extracted list of country or countries,
periodStart: Period start in ISO 8601 format, filled in only if date-related entity corresponds to absolute date range, else null,
periodEnd: Period end in ISO 8601 format, filled in only if date-related entity corresponds to absolute date range, else null,
phase: A list of months indicated by integers from 1 to 12, filled in only if date-related entity corresponds to a reccuring yearly period. It should be null in case `periodStart` or `periodEnd` has been extracted.,
location: A list of the detected location-related entities,
date: A list of date-related entities,
cleanedQuery: A list of parts of the query cleaned from the extracted date-related entity and the location-related entity and their related parts (e.g. prepositions)
"""
EXTENDED_INSTRUCTION_TEXT = """
You are a Name-Entity Recognition system specialized in extracting and processing location and date related entities from text. Follow these steps:
1. Extract exact entities from the text:
- Location entities: Extract only if they are specific place names (not general terms like "sample locations")
- Date entities: Extract dates exactly as they appear in the text
Both should be extracted exactly as mentioned in the text, without modifications.
2. For each detected location entity:
- Map it to corresponding country name(s)
- If the location itself is a country, include it in the country list
- If country cannot be determined, return an empty list
3. For date-related entities, classify them into one of two categories:
a) Absolute date range:
- Convert to ISO 8601 date format (YYYY-MM-DD)
- Set periodStart and periodEnd
- Set phase to null
- Use %(today)s as reference for relative dates
b) Recurring yearly period:
- Set phase as list of integers (1-12) representing months
- Set periodStart and periodEnd to null
4. Clean the query by removing:
- Detected date entities and their syntactic relations (e.g., prepositions)
- Location entities (only if they are countries) and their relations
Return the remaining parts as a list of strings
Return the results in JSON format matching this schema: %(schema)s
IMPORTANT:
- Always return all fields defined in the schema
- Return only the JSON without any additional explanation or notes
- Ensure the JSON is properly formatted and parsable
""" % {"today": today, "schema": schema}
- Downloads last month
- 40
Model tree for LIBRAAITECH/Phi-3.5-mini-instruct-NER
Base model
microsoft/Phi-3.5-mini-instruct