Views
No views yet
Note: This is the GGUF (quantized) version of the model. For the full HuggingFace format model, see the merged model repository.
unsloth/Qwen2.5-1.5B-Instruct1# Clone llama.cpp
2git clone https://github.com/ggerganov/llama.cpp
3cd llama.cpp
4mkdir build && cd build
5cmake .. -DGGML_CUDA=ON
6cmake --build . --config Release -j1# Using llama-cli
2./llama.cpp/build/bin/llama-cli \
3 -m path/to/intent-classifier-q4_k_m.gguf \
4 -p "Context:
5Previous search: Smartphones
6State: SEARCH_RESULTS
7Last command: show_list
8Products (6): iPhone 15 Pro, Samsung Galaxy S24, OnePlus 12, Google Pixel 8, Xiaomi 14, Nothing Phone 2
9Product count: 6
10
11Query: show me that one"
12
13# Using llama-server (for API access)
14./llama.cpp/build/bin/llama-server \
15 -m path/to/intent-classifier-q4_k_m.gguf \
16 --port 80801from llama_cpp import Llama
2
3# Load model
4llm = Llama(
5 model_path="path/to/intent-classifier-q4_k_m.gguf",
6 n_ctx=2048, # Context window
7 n_threads=4 # Number of CPU threads
8)
9
10# Prepare prompt (ChatML format)
11prompt = "<|im_start|>system\nClassify the user's intent based on the query and context. Intent can be: search, show_detail, go_back, or close.<|im_end|>\n<|im_start|>user\nContext:\nPrevious search: Smartphones\nState: SEARCH_RESULTS\nLast command: show_list\nProducts (6): iPhone 15 Pro, Samsung Galaxy S24, OnePlus 12, Google Pixel 8, Xiaomi 14, Nothing Phone 2\nProduct count: 6\n\nQuery: show me that one<|im_end|>\n<|im_start|>assistant\nshow_detail<|im_end|>"
12
13# Generate
14response = llm(
15 prompt,
16 max_tokens=128,
17 temperature=0.7,
18 stop=["<|im_end|>", "<|im_start|>"]
19)
20
21print(response['choices'][0]['text'])Modelfile:1FROM ./intent-classifier-q4_k_m.gguf
2
3TEMPLATE "<|im_start|>system\nClassify the user's intent based on the query and context. Intent can be: search, show_detail, go_back, or close.<|im_end|>\n<|im_start|>user\nContext:\nPrevious search: Smartphones\nState: SEARCH_RESULTS\nLast command: show_list\nProducts (6): iPhone 15 Pro, Samsung Galaxy S24, OnePlus 12, Google Pixel 8, Xiaomi 14, Nothing Phone 2\nProduct count: 6\n\nQuery: show me that one<|im_end|>\n<|im_start|>assistant\nshow_detail<|im_end|>"
4
5PARAMETER temperature 0.7
6PARAMETER num_predict 128
7PARAMETER stop "<|im_end|>"
8PARAMETER stop "<|im_start|>"ollama create intent-classifier -f Modelfile1# Import GGUF file directly
2ollama import intent-classifier-q4_k_m.gguf1# Command line
2ollama run intent-classifier "Context:
3Previous search: Smartphones
4State: SEARCH_RESULTS
5Last command: show_list
6Products (6): iPhone 15 Pro, Samsung Galaxy S24, OnePlus 12, Google Pixel 8, Xiaomi 14, Nothing Phone 2
7Product count: 6
8
9Query: show me that one"
10
11# With context
12ollama run intent-classifier "Context: Previous search: Smartphones\nQuery: show me that one"1import requests
2
3# Generate
4response = requests.post(
5 "http://localhost:11434/api/generate",
6 json={
7 "model": "intent-classifier",
8 "prompt": "Context:
9Previous search: Smartphones
10State: SEARCH_RESULTS
11Last command: show_list
12Products (6): iPhone 15 Pro, Samsung Galaxy S24, OnePlus 12, Google Pixel 8, Xiaomi 14, Nothing Phone 2
13Product count: 6
14
15Query: show me that one",
16 "stream": False,
17 "options": {
18 "temperature": 0.7,
19 "num_predict": 128,
20 "stop": ["<|im_end|>", "<|im_start|>"]
21 }
22 }
23)
24
25print(response.json()["response"])1import requests
2
3response = requests.post(
4 "http://localhost:11434/api/chat",
5 json={
6 "model": "intent-classifier",
7 "messages": [
8 {"role": "system", "content": "Classify the user's intent based on the query and context. Intent can be: search, show_detail, go_back, or close."},
9 {"role": "user", "content": "Context:
10Previous search: Smartphones
11State: SEARCH_RESULTS
12Last command: show_list
13Products (6): iPhone 15 Pro, Samsung Galaxy S24, OnePlus 12, Google Pixel 8, Xiaomi 14, Nothing Phone 2
14Product count: 6
15
16Query: show me that one"}
17 ],
18 "stream": False
19 }
20)
21
22print(response.json()["message"]["content"])Note: vLLM works best with HuggingFace format models. Use the merged model instead of GGUF.
pip install vllm1from vllm import LLM, SamplingParams
2
3# Load merged model (not GGUF)
4llm = LLM(
5 model="mudasir13cs/E-commerce-intent-classifier",
6 trust_remote_code=True,
7 max_model_len=2048
8)
9
10# Prepare prompt
11prompt = "<|im_start|>system\nClassify the user's intent based on the query and context. Intent can be: search, show_detail, go_back, or close.<|im_end|>\n<|im_start|>user\nContext:\nPrevious search: Smartphones\nState: SEARCH_RESULTS\nLast command: show_list\nProducts (6): iPhone 15 Pro, Samsung Galaxy S24, OnePlus 12, Google Pixel 8, Xiaomi 14, Nothing Phone 2\nProduct count: 6\n\nQuery: show me that one<|im_end|>\n<|im_start|>assistant\nshow_detail<|im_end|>"
12
13# Sampling parameters
14sampling_params = SamplingParams(
15 temperature=0.7,
16 max_tokens=128,
17 stop=["<|im_end|>", "<|im_start|>"]
18)
19
20# Generate
21outputs = llm.generate([prompt], sampling_params)
22print(outputs[0].outputs[0].text)1# Start server
2python -m vllm.entrypoints.openai.api_server \
3 --model mudasir13cs/E-commerce-intent-classifier \
4 --trust-remote-code \
5 --port 8000
6
7# Use OpenAI-compatible API
8curl http://localhost:8000/v1/completions \
9 -H "Content-Type: application/json" \
10 -d '{
11 "model": "intent-classifier",
12 "prompt": "Context:
13Previous search: Smartphones
14State: SEARCH_RESULTS
15Last command: show_list
16Products (6): iPhone 15 Pro, Samsung Galaxy S24, OnePlus 12, Google Pixel 8, Xiaomi 14, Nothing Phone 2
17Product count: 6
18
19Query: show me that one",
20 "max_tokens": 128,
21 "temperature": 0.7
22 }'Note: TGI works with HuggingFace format models. Use the merged model.
1# Using Docker (recommended)
2docker pull ghcr.io/huggingface/text-generation-inference:latest1docker run --gpus all \
2 -p 8080:80 \
3 -v /path/to/model:/data \
4 ghcr.io/huggingface/text-generation-inference:latest \
5 --model-id mudasir13cs/E-commerce-intent-classifier \
6 --trust-remote-code1from text_generation import Client
2
3client = Client("http://localhost:8080")
4
5response = client.generate(
6 prompt="<|im_start|>system\nClassify the user's intent based on the query and context. Intent can be: search, show_detail, go_back, or close.<|im_end|>\n<|im_start|>user\nContext:\nPrevious search: Smartphones\nState: SEARCH_RESULTS\nLast command: show_list\nProducts (6): iPhone 15 Pro, Samsung Galaxy S24, OnePlus 12, Google Pixel 8, Xiaomi 14, Nothing Phone 2\nProduct count: 6\n\nQuery: show me that one<|im_end|>\n<|im_start|>assistant\nshow_detail<|im_end|>",
7 max_new_tokens=128,
8 temperature=0.7,
9 stop_sequences=["<|im_end|>", "<|im_start|>"]
10)
11
12print(response.generated_text)Note: Use the merged HuggingFace model for Transformers.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load merged model
5model = AutoModelForCausalLM.from_pretrained(
6 "mudasir13cs/E-commerce-intent-classifier",
7 torch_dtype=torch.bfloat16,
8 device_map="auto",
9 trust_remote_code=True
10)
11tokenizer = AutoTokenizer.from_pretrained(
12 "mudasir13cs/E-commerce-intent-classifier",
13 trust_remote_code=True
14)
15
16# Prepare input
17messages = [
18 {"role": "system", "content": "Classify the user's intent based on the query and context. Intent can be: search, show_detail, go_back, or close."},
19 {"role": "user", "content": "Context:
20Previous search: Smartphones
21State: SEARCH_RESULTS
22Last command: show_list
23Products (6): iPhone 15 Pro, Samsung Galaxy S24, OnePlus 12, Google Pixel 8, Xiaomi 14, Nothing Phone 2
24Product count: 6
25
26Query: show me that one"}
27]
28
29# Apply chat template
30prompt = tokenizer.apply_chat_template(
31 messages,
32 tokenize=False,
33 add_generation_prompt=True
34)
35
36# Generate
37inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
38outputs = model.generate(
39 **inputs,
40 max_new_tokens=128,
41 temperature=0.7,
42 do_sample=True,
43 pad_token_id=tokenizer.eos_token_id
44)
45
46# Decode
47response = tokenizer.decode(
48 outputs[0][inputs.input_ids.shape[1]:],
49 skip_special_tokens=True
50)
51print(response)<|im_start|>system
Classify the user's intent based on the query and context. Intent can be: search, show_detail, go_back, or close.<|im_end|>
<|im_start|>user
Context:
Previous search: Smartphones
State: SEARCH_RESULTS
Last command: show_list
Products (6): iPhone 15 Pro, Samsung Galaxy S24, OnePlus 12, Google Pixel 8, Xiaomi 14, Nothing Phone 2
Product count: 6
Query: show me that one<|im_end|>
<|im_start|>assistant
show_detail<|im_end|>Classify the user's intent based on the query and context. Intent can be: search, show_detail, go_back, or close.Context:
Previous search: [category]
State: [SEARCH_RESULTS|PRODUCT_DETAIL|INITIAL]
Last command: [show_list|show_item|go_back|close]
Products (N): [product1, product2, ...]
Product count: N
Query: [user query]show_detailContext:
Previous search: Smartphones
State: SEARCH_RESULTS
Last command: show_list
Products (6): iPhone 15 Pro, Samsung Galaxy S24, OnePlus 12, Google Pixel 8, Xiaomi 14, Nothing Phone 2
Product count: 6
Query: show me that oneContext:
Previous search: Laptops
State: SEARCH_RESULTS
Last command: show_list
Products (5): MacBook Pro, Dell XPS, HP Spectre, Lenovo ThinkPad, ASUS ZenBook
Product count: 5
Query: under 50000Context:
Previous search: Headphones
State: SEARCH_RESULTS
Last command: show_list
Products (4): Sony WH-1000XM5, Bose QuietComfort, AirPods Max, Sennheiser Momentum
Product count: 4
Query: show me the second one| Format | Size | Quality | Use Case |
|---|---|---|---|
| f16 | ~3GB | Best | Maximum quality, sufficient VRAM |
| q8_0 | ~1.8GB | Excellent | High quality, moderate VRAM |
| q5_k_m | ~1.2GB | Very Good | Balanced quality/size |
| q4_k_m | ~1GB | Good | Smallest size, limited VRAM |
1# Using huggingface-cli
2huggingface-cli download mudasir13cs/E-commerce-intent-classifier-gguf \
3 intent-classifier-q4_k_m.gguf \
4 --local-dir ./models
5
6# Or download all formats
7huggingface-cli download mudasir13cs/E-commerce-intent-classifier-gguf \
8 --local-dir ./modelsmudasir13cs/E-commerce-intent-classifier| Backend | Format | Best For | Pros | Cons |
|---|---|---|---|---|
| llama.cpp | GGUF | CPU/GPU inference, edge devices | Fast, low memory, cross-platform | Limited to GGUF format |
| Ollama | GGUF | Local development, easy deployment | Simple API, auto-manages models | Requires model import |
| vLLM | HF | High-throughput serving | Very fast, batching support | Requires HF format, more memory |
| TGI | HF | Production serving | Optimized serving, Docker support | Requires HF format |
| Transformers | HF | Research, fine-tuning | Full flexibility, easy integration | Slower inference, more memory |
1@software{ecommerce_agent_models,
2 title = {E-commerce Agent Models - Intent Classifier},
3 author = {Syed Mudasir},
4 year = {2025},
5 url = {https://huggingface.co/mudasir13cs/E-commerce-intent-classifier-gguf}
6}