Views
No views yet
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4torch.set_default_device("cuda")
5
6model = AutoModelForCausalLM.from_pretrained("voidful/phi-1_5_chat_32k")
7tokenizer = AutoTokenizer.from_pretrained("voidful/phi-1_5_chat_32k",device_map="auto")
8
9messages = [
10 {
11 "role": "system",
12 "content": "You are a helpful assistant.",
13 },
14 {"role": "user", "content": "how to make a keyboard?"},
15 {"role": "assistant", "content": """To make a keyboard, you will need the following materials:
16
171. A set of keys, such as those found on a standard computer keyboard.
182. A circuit board, such as a MOSFET (Metal-Oxide-Semiconductor-Fluorescent) board.
193. A power supply to provide power to the circuit board.
204. A case to enclose the circuit board and protect it from damage.
215. A soldering iron and solder to connect the components together.
22
23Here is a basic outline of the steps involved in making a keyboard:
24
251. Connect the circuit board to the power supply and the case.
262. Connect the MOSFETs to the power supply and the case, using a soldering iron and solder.
273. Connect the keys to the circuit board, using a soldering iron and solder.
284. Test the keyboard to ensure that it works properly.
295. Package the keyboard in a box or case for shipping or sale.
30
31Note that this is just a basic outline, and there are many additional steps and considerations that will depend on the specific design and requirements of your keyboard.</s>"""},
32 {"role": "user", "content": "where to buy the circuit?"},
33 ]
34tokenized_chat = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt")
35
36outputs = model.generate(tokenized_chat, max_length=1024)
37text = tokenizer.batch_decode(outputs[:,tokenized_chat.shape[-1]:-1])[0]
38print(text)There are several places where you can buy a circuit board. Here are some of the most common places:
1. Electronics stores: Many electronics stores carry a variety of circuit boards for different purposes.
2. Online marketplaces: There are several online marketplaces where you can buy circuit boards, such as Amazon, eBay, and Alibaba.
3. Specialty stores: There are several specialty stores that carry a variety of circuit boards for different purposes, such as hobby stores, craft stores, and home improvement stores.
In general, it is a good idea to shop around and compare prices and features before making a purchase.