Text Generation
Transformers
Safetensors
English
phi3
conversational
custom_code
text-generation-inference
Instructions to use numind/NuExtract with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use numind/NuExtract with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="numind/NuExtract", 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("numind/NuExtract", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("numind/NuExtract", 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use numind/NuExtract with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "numind/NuExtract" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "numind/NuExtract", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/numind/NuExtract
- SGLang
How to use numind/NuExtract 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 "numind/NuExtract" \ --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": "numind/NuExtract", "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 "numind/NuExtract" \ --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": "numind/NuExtract", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use numind/NuExtract with Docker Model Runner:
docker model run hf.co/numind/NuExtract
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SOTA Structure Extraction Model by NuMind 🔥
|
| 2 |
+
|
| 3 |
+
NuExtract is a fine-tuned version of phi-3-small, on a private high-quality syntactic dataset for information extraction. To use the model, provide an input text (less than 2000 tokens) and a JSON schema describing the information you need to extract. This model is purely extractive, so each information output by the model is present as it is in the text. You can also provide an example of output to help the model understand your task more precisely.
|
| 4 |
+
|
| 5 |
+
**Checkout other models by NuMind:**
|
| 6 |
+
* SOTA Zero-shot NER Model [NuNER Zero](https://huggingface.co/numind/NuNER_Zero)
|
| 7 |
+
* SOTA Multilingual Entity Recognition Foundation Model: [link](https://huggingface.co/numind/entity-recognition-multilingual-general-sota-v1)
|
| 8 |
+
* SOTA Sentiment Analysis Foundation Model: [English](https://huggingface.co/numind/generic-sentiment-v1), [Multilingual](https://huggingface.co/numind/generic-sentiment-multi-v1)
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
## Usage
|
| 12 |
+
|
| 13 |
+
To use the model:
|
| 14 |
+
|
| 15 |
+
```python
|
| 16 |
+
|
| 17 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def predict_NuExtract(model,tokenizer,text, schema,example = ["","",""]):
|
| 21 |
+
schema = json.dumps(json.loads(schema), indent=4)
|
| 22 |
+
input_llm = "<|input|>\n### Template:\n" + schema + "\n"
|
| 23 |
+
for i in example:
|
| 24 |
+
if i != "":
|
| 25 |
+
input_llm += "### Example:\n"+ json.dumps(json.loads(i), indent=4)+"\n"
|
| 26 |
+
|
| 27 |
+
input_llm += "### Text:\n"+text +"\n<|output|>\n"
|
| 28 |
+
input_ids = tokenizer(input_llm, return_tensors="pt",truncation = True, max_length = 4000).to("cuda")
|
| 29 |
+
|
| 30 |
+
output = tokenizer.decode(model.generate(**input_ids)[0], skip_special_tokens=True)
|
| 31 |
+
return output.split("<|output|>")[1].split("<|end-output|>")[0]
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
model = AutoModelForCausalLM.from_pretrained("numind/NuExtract", trust_remote_code=True)
|
| 35 |
+
tokenizer = AutoTokenizer.from_pretrained("numind/NuExtract", trust_remote_code=True)
|
| 36 |
+
|
| 37 |
+
#model.to("cuda")
|
| 38 |
+
|
| 39 |
+
model.eval()
|
| 40 |
+
|
| 41 |
+
text = """We introduce Mistral 7B, a 7–billion-parameter language model engineered for
|
| 42 |
+
superior performance and efficiency. Mistral 7B outperforms the best open 13B
|
| 43 |
+
model (Llama 2) across all evaluated benchmarks, and the best released 34B
|
| 44 |
+
model (Llama 1) in reasoning, mathematics, and code generation. Our model
|
| 45 |
+
leverages grouped-query attention (GQA) for faster inference, coupled with sliding
|
| 46 |
+
window attention (SWA) to effectively handle sequences of arbitrary length with a
|
| 47 |
+
reduced inference cost. We also provide a model fine-tuned to follow instructions,
|
| 48 |
+
Mistral 7B – Instruct, that surpasses Llama 2 13B – chat model both on human and
|
| 49 |
+
automated benchmarks. Our models are released under the Apache 2.0 license.
|
| 50 |
+
Code: https://github.com/mistralai/mistral-src
|
| 51 |
+
Webpage: https://mistral.ai/news/announcing-mistral-7b/"""
|
| 52 |
+
|
| 53 |
+
schema = """{
|
| 54 |
+
"Model": {
|
| 55 |
+
"Name": "",
|
| 56 |
+
"Number of parameters": "",
|
| 57 |
+
"Number of token": "",
|
| 58 |
+
"Architecture": []
|
| 59 |
+
},
|
| 60 |
+
"Usage": {
|
| 61 |
+
"Use case": [],
|
| 62 |
+
"Licence": ""
|
| 63 |
+
}
|
| 64 |
+
}"""
|
| 65 |
+
|
| 66 |
+
prediction = predict_NuExtract(model,tokenizer,text, schema,example = ["","",""])
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
```
|