Update README.md
Browse files
README.md
CHANGED
|
@@ -27,18 +27,47 @@ This model is a fine-tuned version of [unsloth/Phi-3-mini-4k-instruct-bnb-4bit](
|
|
| 27 |
|
| 28 |
## 🧠 How to Use
|
| 29 |
|
| 30 |
-
```python
|
| 31 |
from unsloth import FastLanguageModel
|
|
|
|
|
|
|
|
|
|
| 32 |
|
|
|
|
| 33 |
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 34 |
-
"sreebhargav/
|
| 35 |
max_seq_length=2048,
|
| 36 |
load_in_4bit=True,
|
| 37 |
device_map="auto"
|
| 38 |
)
|
| 39 |
FastLanguageModel.for_inference(model)
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
## 🧠 How to Use
|
| 29 |
|
|
|
|
| 30 |
from unsloth import FastLanguageModel
|
| 31 |
+
from transformers import AutoTokenizer
|
| 32 |
+
import torch
|
| 33 |
+
import gradio as gr
|
| 34 |
|
| 35 |
+
# 🔃 Load model and tokenizer from Hugging Face
|
| 36 |
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 37 |
+
model_name="sreebhargav/finetuned-phi3-cli", # Replace with your HF model path
|
| 38 |
max_seq_length=2048,
|
| 39 |
load_in_4bit=True,
|
| 40 |
device_map="auto"
|
| 41 |
)
|
| 42 |
FastLanguageModel.for_inference(model)
|
| 43 |
|
| 44 |
+
# 🔍 CLI Assistant function
|
| 45 |
+
def cli_assistant(prompt):
|
| 46 |
+
messages = [{"role": "user", "content": prompt}]
|
| 47 |
+
inputs = tokenizer.apply_chat_template(
|
| 48 |
+
messages,
|
| 49 |
+
return_tensors="pt",
|
| 50 |
+
tokenize=True,
|
| 51 |
+
add_generation_prompt=True
|
| 52 |
+
).to(model.device)
|
| 53 |
+
|
| 54 |
+
outputs = model.generate(
|
| 55 |
+
input_ids=inputs,
|
| 56 |
+
max_new_tokens=256,
|
| 57 |
+
temperature=0.7,
|
| 58 |
+
top_p=0.9,
|
| 59 |
+
do_sample=True,
|
| 60 |
+
eos_token_id=tokenizer.eos_token_id
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 64 |
+
return decoded.split("### Output:\n")[-1].strip()
|
| 65 |
+
|
| 66 |
+
# 🚀 Launch Gradio demo
|
| 67 |
+
gr.Interface(
|
| 68 |
+
fn=cli_assistant,
|
| 69 |
+
inputs=gr.Textbox(lines=2, placeholder="Ask about a Linux/Git/Bash command..."),
|
| 70 |
+
outputs=gr.Textbox(label="🧠 AI Response"),
|
| 71 |
+
title="🧠 CLI Assistant - Phi-3 Mini + Unsloth",
|
| 72 |
+
description="Ask your command-line questions. This model was fine-tuned with QLoRA using Unsloth."
|
| 73 |
+
).launch(share=True)
|