Text Generation
Transformers
Safetensors
English
gemma3_text
text-generation-inference
unsloth
conversational
Instructions to use Mr-Vicky-01/gemma-qna with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Mr-Vicky-01/gemma-qna with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Mr-Vicky-01/gemma-qna") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("Mr-Vicky-01/gemma-qna") model = AutoModelForMultimodalLM.from_pretrained("Mr-Vicky-01/gemma-qna") 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 Settings
- vLLM
How to use Mr-Vicky-01/gemma-qna with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Mr-Vicky-01/gemma-qna" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Mr-Vicky-01/gemma-qna", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Mr-Vicky-01/gemma-qna
- SGLang
How to use Mr-Vicky-01/gemma-qna 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 "Mr-Vicky-01/gemma-qna" \ --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": "Mr-Vicky-01/gemma-qna", "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 "Mr-Vicky-01/gemma-qna" \ --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": "Mr-Vicky-01/gemma-qna", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use Mr-Vicky-01/gemma-qna 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 Mr-Vicky-01/gemma-qna 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 Mr-Vicky-01/gemma-qna to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Mr-Vicky-01/gemma-qna to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="Mr-Vicky-01/gemma-qna", max_seq_length=2048, ) - Docker Model Runner
How to use Mr-Vicky-01/gemma-qna with Docker Model Runner:
docker model run hf.co/Mr-Vicky-01/gemma-qna
Unsloth Model Card
Browse files
README.md
CHANGED
|
@@ -1,74 +1,21 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
license: apache-2.0
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
-
|
| 13 |
-
tokenizer = AutoTokenizer.from_pretrained("Mr-Vicky-01/gemma-qna")
|
| 14 |
-
model = AutoModelForCausalLM.from_pretrained("Mr-Vicky-01/gemma-qna")
|
| 15 |
|
| 16 |
-
|
| 17 |
-
prompt = """
|
| 18 |
-
<bos><start_of_turn>user
|
| 19 |
-
You are Securitron, Created by Aquilax, a helpful AI assistant specialized in providing accurate and professional responses. Always prioritize clarity and precision in your answers.
|
| 20 |
-
"""
|
| 21 |
-
|
| 22 |
-
# Initialize conversation history
|
| 23 |
-
conversation_history = []
|
| 24 |
-
|
| 25 |
-
# Set up device
|
| 26 |
-
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
| 27 |
-
model.to(device)
|
| 28 |
-
|
| 29 |
-
i=0
|
| 30 |
-
while True:
|
| 31 |
-
user_prompt = input("\nUser Question: ")
|
| 32 |
-
if user_prompt.lower() == 'break':
|
| 33 |
-
break
|
| 34 |
-
|
| 35 |
-
if i==0:
|
| 36 |
-
user_message = f"""
|
| 37 |
-
{user_prompt}<end_of_turn>
|
| 38 |
-
<start_of_turn>model"""
|
| 39 |
-
i+=1
|
| 40 |
-
else:
|
| 41 |
-
user_message = f"""
|
| 42 |
-
<start_of_turn>user
|
| 43 |
-
{user_prompt}<end_of_turn>
|
| 44 |
-
<start_of_turn>model"""
|
| 45 |
-
|
| 46 |
-
# Add the user's question to the conversation history
|
| 47 |
-
conversation_history.append(user_message)
|
| 48 |
-
|
| 49 |
-
# Keep only the last 2 exchanges (4 turns)
|
| 50 |
-
conversation_history = conversation_history[-5:]
|
| 51 |
-
|
| 52 |
-
# Build the full prompt
|
| 53 |
-
current_prompt = prompt + "\n".join(conversation_history)
|
| 54 |
-
|
| 55 |
-
# Tokenize the prompt
|
| 56 |
-
encodeds = tokenizer(current_prompt, return_tensors="pt", truncation=True).input_ids.to(device)
|
| 57 |
-
|
| 58 |
-
# Initialize TextStreamer for real-time token generation
|
| 59 |
-
text_streamer = TextStreamer(tokenizer, skip_prompt=True)
|
| 60 |
-
|
| 61 |
-
# Generate response with TextStreamer
|
| 62 |
-
response = model.generate(
|
| 63 |
-
input_ids=encodeds,
|
| 64 |
-
streamer=text_streamer,
|
| 65 |
-
max_new_tokens=2048,
|
| 66 |
-
use_cache=True,
|
| 67 |
-
pad_token_id=106,
|
| 68 |
-
eos_token_id=106,
|
| 69 |
-
num_return_sequences=1
|
| 70 |
-
)
|
| 71 |
-
|
| 72 |
-
# Finalize conversation history with the assistant's response
|
| 73 |
-
conversation_history.append(tokenizer.decode(response[0]).split('<start_of_turn>model')[-1].split('<end_of_turn>')[0].strip())
|
| 74 |
-
```
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model: unsloth/gemma-3-1b-it-unsloth-bnb-4bit
|
| 3 |
+
tags:
|
| 4 |
+
- text-generation-inference
|
| 5 |
+
- transformers
|
| 6 |
+
- unsloth
|
| 7 |
+
- gemma3_text
|
| 8 |
license: apache-2.0
|
| 9 |
+
language:
|
| 10 |
+
- en
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Uploaded finetuned model
|
| 14 |
|
| 15 |
+
- **Developed by:** Mr-Vicky-01
|
| 16 |
+
- **License:** apache-2.0
|
| 17 |
+
- **Finetuned from model :** unsloth/gemma-3-1b-it-unsloth-bnb-4bit
|
| 18 |
|
| 19 |
+
This gemma3_text model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|