File size: 1,105 Bytes
0428109
79a677f
 
 
 
 
 
 
 
b806fbd
79a677f
 
 
 
 
 
2a5f539
79a677f
 
 
 
 
b806fbd
 
79a677f
b806fbd
 
b7dcb2f
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
import gradio as gr
from llm_rs import AutoModel,SessionConfig,GenerationConfig,Precision

repo_name = "rustformers/mpt-7b-ggml"
file_name = "mpt-7b-instruct-q5_1-ggjt.bin"

session_config = SessionConfig(threads=2,batch_size=2)
model = AutoModel.from_pretrained(repo_name, model_file=file_name, session_config=session_config,verbose=True)

def process_stream(instruction):

    prompt=f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{instruction}
### Response:
Answer:"""
    generation_config = GenerationConfig(seed=40,temperature=0.1,top_p=0.15,top_k=20,max_new_tokens=1000)
    response = ""
    streamer = model.stream(prompt=prompt,generation_config=generation_config)
    for new_text in streamer:
        response += new_text
        yield response
inputs = gr.inputs.Textbox(lines=7, label="Chat with AI")
outputs = gr.outputs.Textbox(label="Reply")

gr.Interface(fn=process_stream, inputs=inputs, outputs=outputs, title="Self_Trained_V2",
             description="Ask anything you want",
             ).launch()