File size: 927 Bytes
c5bef22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ede08f0
c5bef22
 
 
ede08f0
 
 
 
 
 
 
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
---
license: apache-2.0
datasets:
- Laurie/alpaca_chinese_dataset
language:
- zh
- en
metrics:
- accuracy
library_name: transformers
pipeline_tag: text2text-generation
---
## Usage:

    from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
    import torch
    
    tokenizer = AutoTokenizer.from_pretrained("baichuan7b-lora-merged", trust_remote_code=True)
    model = AutoModelForCausalLM.from_pretrained("baichuan7b-lora-merged", device_map="auto", trust_remote_code=True,torch_dtype=torch.float16)
    streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
    while True:
        query = input('请输入问题:')
        if len(query.strip()) == 0:
            break
        inputs = tokenizer(["<human>:{}\n<bot>:".format(query)], return_tensors="pt")
        inputs = inputs.to("cuda")
        generate_ids = model.generate(**inputs, max_new_tokens=256, streamer=streamer)