Views
No views yet

system_prompt = 'Below is an instruction that describes a task. Write a response that appropriately completes the request\n'
B_INST, E_INST = "### Instruction:\n", "### Response:\n"
prompt = f"{system_prompt}{B_INST}{user_prompt.strip()}\n\n{E_INST}"<s>Below is an instruction that describes a task. Write a response that appropriately completes the request
### Instruction:
explain newtoen's 3rd law with example
### Response:1Here's a simple example to illustrate this law:
2
3Imagine you're on a skateboard, and you push against a wall with your foot. When you apply force (the action) to the wall by pushing, the wall pushes back on your foot with an equal force in the opposite direction (the reaction). This is why you can feel the wall pushing against your foot.
4
5Another everyday example is when you walk. As your foot pushes backward against the ground (action), the ground pushes your foot forward with an equal force (reaction), propelling you forward.
6
7Newton's Third Law helps explain how objects move and interact with each other, emphasizing that forces always come in pairs and act in opposite directions.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer, pipeline
3model = AutoModelForCausalLM.from_pretrained("gathnex/gathllama-2", load_in_4bit = True)
4tokenizer = AutoTokenizer.from_pretrained("gathnex/gathllama-2")
5# for better inference
6model.config.use_cache = True
7model.eval()
8#testing
9def stream(user_prompt):
10 runtimeFlag = "cuda:0"
11 system_prompt = 'Below is an instruction that describes a task. Write a response that appropriately completes the request'
12 B_INST, E_INST = "### Instruction:\n", "### Response:\n"
13
14 prompt = f"{system_prompt}{B_INST}{user_prompt.strip()}\n\n{E_INST}"
15
16 inputs = tokenizer([prompt], return_tensors="pt",add_special_tokens=False).to(runtimeFlag)
17
18 streamer = TextStreamer(tokenizer, skip_prompt=True,
19 skip_special_tokens=True)
20
21 # Despite returning the usual output, the streamer will also print the generated text to stdout.
22 _ = model.generate(**inputs, streamer=streamer, max_new_tokens=500)
23
24stream("explain how to impress our CEO, i'm joined 5 month ago in the company. give tips and tricks")