Instructions to use llmware/slim-extract-phi-3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use llmware/slim-extract-phi-3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="llmware/slim-extract-phi-3", 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("llmware/slim-extract-phi-3", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("llmware/slim-extract-phi-3", 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 llmware/slim-extract-phi-3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "llmware/slim-extract-phi-3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "llmware/slim-extract-phi-3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/llmware/slim-extract-phi-3
- SGLang
How to use llmware/slim-extract-phi-3 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 "llmware/slim-extract-phi-3" \ --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": "llmware/slim-extract-phi-3", "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 "llmware/slim-extract-phi-3" \ --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": "llmware/slim-extract-phi-3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use llmware/slim-extract-phi-3 with Docker Model Runner:
docker model run hf.co/llmware/slim-extract-phi-3
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,19 +1,15 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
| 3 |
inference: false
|
| 4 |
---
|
| 5 |
|
| 6 |
-
# SLIM-EXTRACT
|
| 7 |
|
| 8 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
| 9 |
|
| 10 |
-
**slim-extract** implements a specialized function-calling customizable 'extract' capability that takes as an input a context passage, a customized key, and outputs a python dictionary with key that corresponds to the customized key, with a value consisting of a list of items extracted from the text corresponding to that key, e.g.,
|
| 11 |
|
| 12 |
`{'universities': ['Berkeley, Stanford, Yale, University of Florida, ...'] }`
|
| 13 |
|
| 14 |
-
This model is fine-tuned on top of [**llmware/bling-stable-lm-3b-4e1t-v0**](https://huggingface.co/llmware/bling-stable-lm-3b-4e1t-v0), which in turn, is a fine-tune of stabilityai/stablelm-3b-4elt.
|
| 15 |
-
|
| 16 |
-
For fast inference use, we would recommend the 'quantized tool' version, e.g., [**'slim-extract-tool'**](https://huggingface.co/llmware/slim-extract-tool).
|
| 17 |
|
| 18 |
|
| 19 |
## Prompt format:
|
|
@@ -27,8 +23,8 @@ For fast inference use, we would recommend the 'quantized tool' version, e.g.,
|
|
| 27 |
<details>
|
| 28 |
<summary>Transformers Script </summary>
|
| 29 |
|
| 30 |
-
model = AutoModelForCausalLM.from_pretrained("llmware/slim-extract")
|
| 31 |
-
tokenizer = AutoTokenizer.from_pretrained("llmware/slim-extract")
|
| 32 |
|
| 33 |
function = "extract"
|
| 34 |
params = "company"
|
|
@@ -70,7 +66,7 @@ For fast inference use, we would recommend the 'quantized tool' version, e.g.,
|
|
| 70 |
<summary>Using as Function Call in LLMWare</summary>
|
| 71 |
|
| 72 |
from llmware.models import ModelCatalog
|
| 73 |
-
slim_model = ModelCatalog().load_model("llmware/slim-extract")
|
| 74 |
response = slim_model.function_call(text,params=["company"], function="extract")
|
| 75 |
|
| 76 |
print("llmware - llm_response: ", response)
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
inference: false
|
| 4 |
---
|
| 5 |
|
| 6 |
+
# SLIM-EXTRACT-PHI-3
|
| 7 |
|
|
|
|
| 8 |
|
| 9 |
+
**slim-extract-phi-3** implements a specialized function-calling customizable 'extract' capability that takes as an input a context passage, a customized key, and outputs a python dictionary with key that corresponds to the customized key, with a value consisting of a list of items extracted from the text corresponding to that key, e.g.,
|
| 10 |
|
| 11 |
`{'universities': ['Berkeley, Stanford, Yale, University of Florida, ...'] }`
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
## Prompt format:
|
|
|
|
| 23 |
<details>
|
| 24 |
<summary>Transformers Script </summary>
|
| 25 |
|
| 26 |
+
model = AutoModelForCausalLM.from_pretrained("llmware/slim-extract-phi-3")
|
| 27 |
+
tokenizer = AutoTokenizer.from_pretrained("llmware/slim-extract-phi-3")
|
| 28 |
|
| 29 |
function = "extract"
|
| 30 |
params = "company"
|
|
|
|
| 66 |
<summary>Using as Function Call in LLMWare</summary>
|
| 67 |
|
| 68 |
from llmware.models import ModelCatalog
|
| 69 |
+
slim_model = ModelCatalog().load_model("llmware/slim-extract-phi-3")
|
| 70 |
response = slim_model.function_call(text,params=["company"], function="extract")
|
| 71 |
|
| 72 |
print("llmware - llm_response: ", response)
|