File size: 1,173 Bytes
e21b443
 
602d649
19a6bcf
e21b443
19a6bcf
e21b443
 
c206cc0
 
e21b443
 
 
602d649
e21b443
602d649
e21b443
 
 
 
 
602d649
e21b443
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
602d649
e21b443
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
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
import gradio as gr

torch.random.manual_seed(0)

model = AutoModelForCausalLM.from_pretrained(
    "savage1221/lora-fine", 
    # device_map="cuda", 
    # torch_dtype="auto", 
    trust_remote_code=True, 
)
tokenizer = AutoTokenizer.from_pretrained("savage1221/lora-fine",trust_remote_code=True)

instruction = "Generate quotes for AWS RDS services"

pipe = pipeline(
    "text-generation",
    model=model,
    tokenizer=tokenizer,
)

generation_args = {
    "max_new_tokens": 500,
    "return_full_text": False,
    "temperature": 0.9,
    "do_sample": True,
    "top_k": 50,
    "top_p": 0.95,
    "num_return_sequences": 1,
}

def predict_price(input_data):
    prompt = f"{instruction}\nInput: {input_data}\nOutput:"
    output = pipe(prompt, **generation_args)
    return output[0]['generated_text']

interface = gr.Interface(
    fn=predict_price,
    inputs=gr.inputs.Textbox(lines=7, label="θΎ“ε…₯商品俑息"),
    outputs=gr.outputs.Textbox(label="ι’„ζ΅‹δ»·ζ Ό"),
    title="商品价格钄桋",
    description="θΎ“ε…₯商品俑息,钄桋商品价格",
)

interface.launch()