|
|
--- |
|
|
license: mit |
|
|
tags: |
|
|
- unsloth |
|
|
- phi-3 |
|
|
- command-line |
|
|
- cli |
|
|
- lora |
|
|
- fine-tuned |
|
|
base_model: |
|
|
- unsloth/Phi-3-mini-4k-instruct-bnb-4bit |
|
|
fine-tuned with: |
|
|
- https://github.com/unslothai/unsloth |
|
|
LoRA config: |
|
|
- r=8, alpha=128, dropout=0 |
|
|
--- |
|
|
|
|
|
# π οΈ Finetuned Phi-3 CLI Assistant |
|
|
|
|
|
This model is a fine-tuned version of [unsloth/Phi-3-mini-4k-instruct-bnb-4bit](https://huggingface.co/unsloth/Phi-3-mini-4k-instruct-bnb-4bit), trained on a command-line Q&A dataset for Linux/Git/tar/curl/grep/etc. |
|
|
|
|
|
## π Use Cases |
|
|
|
|
|
- Terminal helpbots |
|
|
- CLI Q&A agents |
|
|
- Developer assistants |
|
|
|
|
|
## π§ How to Use |
|
|
|
|
|
```python |
|
|
from unsloth import FastLanguageModel |
|
|
from transformers import AutoTokenizer |
|
|
import torch |
|
|
import gradio as gr |
|
|
|
|
|
# π Load model and tokenizer from Hugging Face |
|
|
model, tokenizer = FastLanguageModel.from_pretrained( |
|
|
model_name="sreebhargav/finetuned-phi3-cli", # Your HF model path |
|
|
max_seq_length=2048, |
|
|
load_in_4bit=True, |
|
|
device_map="auto" |
|
|
) |
|
|
FastLanguageModel.for_inference(model) |
|
|
|
|
|
# π CLI Assistant function |
|
|
def cli_assistant(prompt): |
|
|
messages = [{"role": "user", "content": prompt}] |
|
|
inputs = tokenizer.apply_chat_template( |
|
|
messages, |
|
|
return_tensors="pt", |
|
|
tokenize=True, |
|
|
add_generation_prompt=True |
|
|
).to(model.device) |
|
|
|
|
|
outputs = model.generate( |
|
|
input_ids=inputs, |
|
|
max_new_tokens=256, |
|
|
temperature=0.7, |
|
|
top_p=0.9, |
|
|
do_sample=True, |
|
|
eos_token_id=tokenizer.eos_token_id |
|
|
) |
|
|
|
|
|
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True) |
|
|
return decoded.split("### Output:\n")[-1].strip() |
|
|
|
|
|
# π Launch Gradio demo |
|
|
gr.Interface( |
|
|
fn=cli_assistant, |
|
|
inputs=gr.Textbox(lines=2, placeholder="Ask about a Linux/Git/Bash command..."), |
|
|
outputs=gr.Textbox(label="π§ AI Response"), |
|
|
title="π§ CLI Assistant - Phi-3 Mini + Unsloth", |
|
|
description="Ask your command-line questions. This model was fine-tuned with QLoRA using Unsloth." |
|
|
).launch(share=True) |