File size: 1,167 Bytes
86be357
 
 
 
 
 
 
 
 
 
 
 
afbb139
 
8dd83e6
 
86be357
 
 
 
37198ae
86be357
 
8dd83e6
37198ae
 
 
 
 
 
 
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
from transformers import AutoTokenizer, AutoModelForCausalLM
import gradio as gr

model_id = "RWKV/rwkv-raven-1b5"

model = AutoModelForCausalLM.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)


def chat(question):
    prompt = f"### Instruction: {question}\n### Response:"
    inputs = tokenizer(prompt, return_tensors="pt")
    output = model.generate(inputs["input_ids"], max_new_tokens=500)
    response = tokenizer.decode(output[0].tolist(), skip_special_tokens=True)
    print(response)
    return response

iface = gr.Interface(fn=chat,
                     inputs=gr.inputs.Textbox(label="Enter your text"),
                     outputs="text",
                     title="Chat with Raven")

# index = construct_index("docs")
iface.launch()



### Instruction: How do I train the RWKV on specific data?
### Response: To train the RWKV on specific data, you can use the `train_rwkv` 
# function from the `sklearn.model_selection` module. 
# This function takes a list of data points as input and returns a list of predictions for each data point. You can then use this list of predictions to train the RWKV on your specific data.