Instructions to use llmware/slim-qa-gen-tiny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use llmware/slim-qa-gen-tiny with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="llmware/slim-qa-gen-tiny")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("llmware/slim-qa-gen-tiny") model = AutoModelForCausalLM.from_pretrained("llmware/slim-qa-gen-tiny") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use llmware/slim-qa-gen-tiny with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "llmware/slim-qa-gen-tiny" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "llmware/slim-qa-gen-tiny", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/llmware/slim-qa-gen-tiny
- SGLang
How to use llmware/slim-qa-gen-tiny 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-qa-gen-tiny" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "llmware/slim-qa-gen-tiny", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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-qa-gen-tiny" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "llmware/slim-qa-gen-tiny", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use llmware/slim-qa-gen-tiny with Docker Model Runner:
docker model run hf.co/llmware/slim-qa-gen-tiny
Update README.md
Browse files
README.md
CHANGED
|
@@ -3,23 +3,23 @@ license: apache-2.0
|
|
| 3 |
inference: false
|
| 4 |
---
|
| 5 |
|
| 6 |
-
# SLIM-
|
| 7 |
|
| 8 |
<!-- Provide a quick summary of what the model is/does. -->
|
| 9 |
|
| 10 |
-
**slim-
|
| 11 |
|
| 12 |
-
`{'question': ['What were earnings per share in the most recent quarter?'] }
|
| 13 |
|
| 14 |
-
This model is finetuned on top of
|
| 15 |
|
| 16 |
-
For fast inference use, we would recommend the 'quantized tool' version, e.g., [**'slim-
|
| 17 |
|
| 18 |
|
| 19 |
## Prompt format:
|
| 20 |
|
| 21 |
`function = "generate"`
|
| 22 |
-
`params = "{'question', 'boolean', or 'multiple choice'}"`
|
| 23 |
`prompt = "<human> " + {text} + "\n" + `
|
| 24 |
`"<{function}> " + {params} + "</{function}>" + "\n<bot>:"`
|
| 25 |
|
|
@@ -27,8 +27,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-
|
| 31 |
-
tokenizer = AutoTokenizer.from_pretrained("llmware/slim-
|
| 32 |
|
| 33 |
function = "generate"
|
| 34 |
params = "boolean"
|
|
@@ -53,7 +53,7 @@ For fast inference use, we would recommend the 'quantized tool' version, e.g.,
|
|
| 53 |
|
| 54 |
print("output only: ", output_only)
|
| 55 |
|
| 56 |
-
[OUTPUT]: {'llm_response': {'question': ['Did Telsa stock decline more than
|
| 57 |
|
| 58 |
# here's the fun part
|
| 59 |
try:
|
|
@@ -72,7 +72,7 @@ For fast inference use, we would recommend the 'quantized tool' version, e.g.,
|
|
| 72 |
<summary>Using as Function Call in LLMWare</summary>
|
| 73 |
|
| 74 |
from llmware.models import ModelCatalog
|
| 75 |
-
slim_model = ModelCatalog().load_model("llmware/slim-
|
| 76 |
response = slim_model.function_call(text,params=["boolean"], function="generate")
|
| 77 |
|
| 78 |
print("llmware - llm_response: ", response)
|
|
|
|
| 3 |
inference: false
|
| 4 |
---
|
| 5 |
|
| 6 |
+
# SLIM-QA-GEN-TINY
|
| 7 |
|
| 8 |
<!-- Provide a quick summary of what the model is/does. -->
|
| 9 |
|
| 10 |
+
**slim-qa-gen-tiny** implements a specialized function-calling question generation and answer from a context passage, with output in the form of a python dictionary, e.g.,
|
| 11 |
|
| 12 |
+
`{'question': ['What were earnings per share in the most recent quarter?'], 'answer': [$3.36]}`
|
| 13 |
|
| 14 |
+
This model is finetuned on top of a tinyllama 1.1b base.
|
| 15 |
|
| 16 |
+
For fast inference use, we would recommend the 'quantized tool' version, e.g., [**'slim-qa-gen-tiny-tool'**](https://huggingface.co/llmware/slim-qa-gen-tiny-tool).
|
| 17 |
|
| 18 |
|
| 19 |
## Prompt format:
|
| 20 |
|
| 21 |
`function = "generate"`
|
| 22 |
+
`params = "{'question, answer', 'boolean', or 'multiple choice'}"`
|
| 23 |
`prompt = "<human> " + {text} + "\n" + `
|
| 24 |
`"<{function}> " + {params} + "</{function}>" + "\n<bot>:"`
|
| 25 |
|
|
|
|
| 27 |
<details>
|
| 28 |
<summary>Transformers Script </summary>
|
| 29 |
|
| 30 |
+
model = AutoModelForCausalLM.from_pretrained("llmware/slim-qa-gen-tiny")
|
| 31 |
+
tokenizer = AutoTokenizer.from_pretrained("llmware/slim-qa-gen-tiny")
|
| 32 |
|
| 33 |
function = "generate"
|
| 34 |
params = "boolean"
|
|
|
|
| 53 |
|
| 54 |
print("output only: ", output_only)
|
| 55 |
|
| 56 |
+
[OUTPUT]: {'llm_response': {'question': ['Did Telsa stock decline more than 5% yesterday?'], 'answer': ['yes']} }
|
| 57 |
|
| 58 |
# here's the fun part
|
| 59 |
try:
|
|
|
|
| 72 |
<summary>Using as Function Call in LLMWare</summary>
|
| 73 |
|
| 74 |
from llmware.models import ModelCatalog
|
| 75 |
+
slim_model = ModelCatalog().load_model("llmware/slim-qa-gen-tiny", sample=True, temperature=0.7)
|
| 76 |
response = slim_model.function_call(text,params=["boolean"], function="generate")
|
| 77 |
|
| 78 |
print("llmware - llm_response: ", response)
|