File size: 1,803 Bytes
e3e29c0 57989ae e3e29c0 57989ae e3e29c0 67643a3 e3e29c0 57989ae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
---
language:
- uz
license: apache-2.0
tags:
- text-generation-inference
- transformers
- unsloth
- llama
- trl
base_model: llama-3-8b-bnb-4bit
---
# Uploaded model
# Usage model.
```
import gradio as gr
from unsloth import FastLanguageModel
# Load your pre-trained model
max_seq_length = 2048
dtype = None
load_in_4bit = True
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="blackhole33/llama-3-8b-bnb-4bit",
max_seq_length=max_seq_length,
dtype=dtype,
load_in_4bit=load_in_4bit,
)
FastLanguageModel.for_inference(model) # Enable native 2x faster inference
# Alpaca prompt template
alpaca_prompt = """Quyida vazifani tavsiflovchi ko'rsatma mavjud bo'lib, u qo'shimcha kontekstni ta'minlaydigan kiritish bilan bog'langan. So'rovni to'g'ri to'ldiradigan javob yozing.
### Instruction:
{}
### Response:
{}"""
# Function to generate response
def generate_response(instruction):
inputs = tokenizer(
[
alpaca_prompt.format(
instruction, # instruction
"" # output - leave this blank for generation!
)
],
return_tensors="pt",
).to("cuda")
outputs = model.generate(**inputs, max_new_tokens=250, use_cache=True)
res = tokenizer.batch_decode(outputs, skip_special_tokens=True)
return res[0]
# Gradio interface
interface = gr.Interface(
fn=generate_response,
inputs=[
gr.Textbox(lines=2, placeholder="Question"),
],
outputs="text",
title="Uzbek Language Model Interface",
description="Enter an instruction and context to get a response from the model.",
)
# Launch the interface
interface.launch(share=True)
```
- **Developed by:** blackhole33
- **License:** apache-2.0
- **Finetuned from model :** llama-3-8b-bnb-4bit
|