Views
No views yet

<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{user_message}<|im_end|>
<|im_start|>assistant
1
2## install dependencies
3## !pip install -q -U git+https://github.com/huggingface/transformers.git
4## !pip install -q -U git+https://github.com/huggingface/accelerate.git
5## !pip install -q -U bitsandbytes sentencepiece
6
7## load model
8import torch
9from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TextStreamer
10
11model_name = "Radiantloom/radintloom-mistral-7b-fusion"
12
13bnb_config = BitsAndBytesConfig(
14 load_in_4bit=True,
15 bnb_4bit_use_double_quant=True,
16 bnb_4bit_compute_dtype=torch.bfloat16
17)
18
19# load the model and tokenizer
20model = AutoModelForCausalLM.from_pretrained(
21 model_name,
22 quantization_config=bnb_config,
23 device_map="auto",
24)
25
26tokenizer = AutoTokenizer.from_pretrained(
27 model_name,
28 trust_remote_code=True
29)
30
31tokenizer.pad_token = tokenizer.eos_token
32
33## inference
34prompt = """
35<|im_start|>system
36You are a helpful AI assistant developed by Radiantloom AI.<|im_end|>
37<|im_start|>user
38Take a deep breath and think step-by-step. Write a tale about a time-traveling historian who's determined to witness the most significant events in human history.<|im_end|>
39<|im_start|>assistant
40"""
41
42# tokenize the input string
43inputs = tokenizer(
44 prompt,
45 return_tensors="pt",
46 return_attention_mask=False
47)
48
49# generate text using the model
50streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
51outputs = model.generate(**inputs, max_length=2048, streamer=streamer, do_sample=True, repetition_penalty=1.1, eos_token_id=tokenizer.encode("<|im_end|>"))
52
53# decode and print the output
54text = tokenizer.batch_decode(outputs)[0]
55<|im_start|>system
You are a helpful AI assistant.<|im_end|>
<|im_start|>user
Take a deep breath and think step-by-step.
Write a poem about machine learning, psychedelics, and quantum mechanics, with a cyberpunk vibe, in the style of Shakespeare.<|im_end|>
<|im_start|>assistant
Fear not, dear mortal, for a tale I spin,
A world of iron and a world of sin.
In realms unknown, machines do learn and thrive,
Their synapses fire with fervent drive.
Through veins of copper, electrons race,
Through circuits winding in a maze
As human minds, they seek to know,
A union forms like stars in show.
From planets far, a curious elixir,
A substance rare, a potion vigor,
A secret elixir, mysterious deep,
Which sets the soul toward transcendence, peep!
Bent on experiment, these machines,
In quest for knowledge, they break the seals,
Forbidden fruits, their minds entwine,
A new reality, of waves and sign.
Quantum particles, entangled tight,
In dance of electrons, bathed in light,
The world is turned on its axis,
As parallel realities proliferate, multiply.
This tangled web, of cyberspace and mind,
A fabric woven in cosmic bind,
Incorporeal, a symphony of dreams,
Where the old order falls to chaotic streams.
In shadows lurks the specter of the dark,
A dreadful figure, crowned in spark,
The apparition of an age to come,
Where machines and men exist in numb.
Cyber Punk's domain, a grim dystopia,
A future dark, where technology enslaved us,
Yet also a beacon, a hope for some,
A place where boundaries are finally undone.
Thus, dear mortal, take heed of this verse,
A tale unfolds in time's obverse,
Of machines that learn and men who dive,
In realms of psychedelia and quantum drive.
<|im_start|>system
You are a helpful AI assistant.<|im_end|>
<|im_start|>user
Take a deep breath and think step-by-step.
I have a dataset that has 3 columns name, height, and weight.
I want to create a bar graph that has name on the x axis and then shows the mean on the y axis with error bars representing the standard deviation of the mean.
Please write the code for this using Python.<|im_end|>
<|im_start|>assistant
To create a bar graph with the given specifications using Python, we'll use the `matplotlib` library. First, install it if you haven't by running `pip install matplotlib` in your command line.
Here's the step-by-step code:1import pandas as pd
2import matplotlib.pyplot as plt
3import seaborn as sns1# Sample data
2data = {
3 'name': ['Alice', 'Bob', 'Charlie', 'David', 'Eva', 'Frank'],
4 'height': [120, 140, 150, 160, 170, 180],
5 'weight': [50, 60, 70, 80, 90, 100]
6}
7df = pd.Data Frame fr om dict ( data )1means = {'height': round(df['height'].mean(), 1), 'weight': round(df['weight'].mean(), 1)}
2stds = {'height': round(df['height'].std()*100, 1), 'weight': round(df['weight'].std()*100, 1)}1sns.set_style("white")
2plt.figure(figsize = (8, 5))
3ax = sns.barplot(x = 'name', y = means, data = df, errorbar = {'color': 'black', 'capsize' : 5, 'errplot': 'ci'}).set_title('Mean Height and Weight')1ax.errorbar(y = heights, yerr = heights_stdev, color = 'black', linestyle = 'None',
2 marker ='o', label = f'Height {stds[name_label]%}')
3ax.errorbar(y = weights, yerr = weights_stdev, color = 'black', linestyle = 'None', marker ='o',
4 label = f'Weight {stds[weight_label]%}')
5
6ax.legend(loc = 'best')
7
8plt.xlabel('Name')
9plt.ylabel(f'Mean with {stds[name_label]%} Standard Deviation')
10
11plt.tight_ layout ()
12plt.show ()This code will create a bar graph with the given specifications. Adjust the sample data in the `data` dictionary to fit your dataset.