Instructions to use rahulvk007/ExtractQueNumberMini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rahulvk007/ExtractQueNumberMini with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rahulvk007/ExtractQueNumberMini")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("rahulvk007/ExtractQueNumberMini") model = AutoModelForCausalLM.from_pretrained("rahulvk007/ExtractQueNumberMini") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use rahulvk007/ExtractQueNumberMini with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rahulvk007/ExtractQueNumberMini" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rahulvk007/ExtractQueNumberMini", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/rahulvk007/ExtractQueNumberMini
- SGLang
How to use rahulvk007/ExtractQueNumberMini 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 "rahulvk007/ExtractQueNumberMini" \ --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": "rahulvk007/ExtractQueNumberMini", "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 "rahulvk007/ExtractQueNumberMini" \ --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": "rahulvk007/ExtractQueNumberMini", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Unsloth Studio new
How to use rahulvk007/ExtractQueNumberMini with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for rahulvk007/ExtractQueNumberMini to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for rahulvk007/ExtractQueNumberMini to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for rahulvk007/ExtractQueNumberMini to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="rahulvk007/ExtractQueNumberMini", max_seq_length=2048, ) - Docker Model Runner
How to use rahulvk007/ExtractQueNumberMini with Docker Model Runner:
docker model run hf.co/rahulvk007/ExtractQueNumberMini
Update README.md
Browse files
README.md
CHANGED
|
@@ -10,14 +10,66 @@ tags:
|
|
| 10 |
- llama
|
| 11 |
- trl
|
| 12 |
- sft
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
-
#
|
| 16 |
|
| 17 |
-
- **Developed by:** rahulvk007
|
| 18 |
-
- **License:**
|
| 19 |
-
- **
|
|
|
|
| 20 |
|
| 21 |
-
This
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
- llama
|
| 11 |
- trl
|
| 12 |
- sft
|
| 13 |
+
datasets:
|
| 14 |
+
- rahulvk007/quenumber_extraction_v2
|
| 15 |
---
|
| 16 |
|
| 17 |
+
# ExtractQueNumberMini Model
|
| 18 |
|
| 19 |
+
- **Developed by:** [rahulvk007](https://github.com/rahulvk007) ([rahulvk.com](https://www.rahulvk.com))
|
| 20 |
+
- **License:** [Apache-2.0](https://opensource.org/licenses/Apache-2.0)
|
| 21 |
+
- **Base Model:** [unsloth/SmolLM2-135M](https://huggingface.co/unsloth/SmolLM2-135M)
|
| 22 |
+
- **Finetuning**: Optimized with [Unsloth](https://github.com/unslothai/unsloth) and [Hugging Face's TRL library](https://github.com/huggingface/trl)
|
| 23 |
|
| 24 |
+
This model has been fine-tuned for quick extraction of question numbers from OCRed handwritten text. It is designed to run efficiently on CPU due to its compact size.
|
| 25 |
|
| 26 |
+
### Model Usage
|
| 27 |
+
|
| 28 |
+
To use this model, set the system prompt to the following:
|
| 29 |
+
|
| 30 |
+
> **Extract the question number from the given text. Your response should be just an integer representing the question number. Do not provide any explanation or context. Just the number.**
|
| 31 |
+
|
| 32 |
+
### Inference Code Example
|
| 33 |
+
|
| 34 |
+
```python
|
| 35 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 36 |
+
|
| 37 |
+
checkpoint = "rahulvk007/ExtractQueNumberMini"
|
| 38 |
+
device = "cpu" # change to "cuda" for GPU
|
| 39 |
+
|
| 40 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 41 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
|
| 42 |
+
|
| 43 |
+
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
| 44 |
+
|
| 45 |
+
### Instruction:
|
| 46 |
+
{}
|
| 47 |
+
|
| 48 |
+
### Input:
|
| 49 |
+
{}
|
| 50 |
+
|
| 51 |
+
### Response:
|
| 52 |
+
{}"""
|
| 53 |
+
|
| 54 |
+
inputs = tokenizer(
|
| 55 |
+
[
|
| 56 |
+
alpaca_prompt.format(
|
| 57 |
+
"Extract the question number from the given text. Your response should be just an integer which is the question number. Do not provide any explanation or context. Just the number.",
|
| 58 |
+
"<Give OCR Text here>",
|
| 59 |
+
"",
|
| 60 |
+
)
|
| 61 |
+
],
|
| 62 |
+
return_tensors="pt"
|
| 63 |
+
).to(device)
|
| 64 |
+
|
| 65 |
+
outputs = model.generate(**inputs, max_new_tokens=64, use_cache=True)
|
| 66 |
+
print(tokenizer.batch_decode(outputs, skip_special_tokens=True))
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
### Datasets
|
| 70 |
+
|
| 71 |
+
The model was fine-tuned on [rahulvk007/quenumber_extraction_v2](https://huggingface.co/datasets/rahulvk007/quenumber_extraction_v2), specifically curated for this task.
|
| 72 |
+
|
| 73 |
+
---
|
| 74 |
+
|
| 75 |
+
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|