how run

#1
by rakmik - opened

Do the files need to be downloaded manually?
Can you provide code to run the heuristics?

code for Inference ???????

Full code for the Inference
If you allow
If possible, the Colab T4 page

from safetensors.torch import load_file
from transformers import BloomForCausalLM, BloomTokenizerFast
import re
import torch

Load BLT-1B model weights

model_weights = load_file('/content/safetensors/blt_1b/consolidated.safetensors')

Load entropy model weights (if needed)

entropy_weights = load_file('/content/safetensors/entropy_model/consolidated.safetensors')

Initialize the Bloom model and tokenizer

model = BloomForCausalLM.from_pretrained("bigscience/bloom-560m")
tokenizer = BloomTokenizerFast.from_pretrained("bigscience/bloom-560m")

Load the BLT-1B weights into the model (with strict=False)

model.load_state_dict(model_weights, strict=False)
model.eval() # Put the model in evaluation mode

Input text for inference

input_text = "who is ai?" # Replace with your desired input text

Tokenize the input text using the Bloom tokenizer

input_ids = tokenizer(input_text, return_tensors="pt").input_ids
input_ids = input_ids.to(torch.device("cuda" if torch.cuda.is_available() else "cpu")) # Move to appropriate device

Generate output with adjusted parameters

with torch.no_grad():
output = model.generate(
input_ids,
max_new_tokens=128,
temperature=0.2,
top_k=30,
top_p=0.50,
repetition_penalty=1.2
)

Decode the output to get the generated text

decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)

Print the generated text

print(decoded_output)

who is ai?"

"I am the one who has been sent to kill you. I have come here for
your sake, and if it be not your will that we should meet again,
you must go away now; but let us wait till our time comes when my son may die.
I shall tell him all about this affair in a few days' time; then he can do his best.

"You are right! You cannot leave me alone with such an innocent child as mine!
You know how much love there was between them both before they were born?
And yet what could she possibly want from her father?

"But why did Mr Huxley send

؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟

from safetensors.torch import load_file
from transformers import AutoTokenizer, AutoModelForCausalLM
import re
import torch
import accelerate

Load BLT-1B model weights

model_weights = load_file('/content/safetensors/blt_1b/consolidated.safetensors')

Load entropy model weights (if needed)

entropy_weights = load_file('/content/safetensors/entropy_model/consolidated.safetensors')

Initialize the Bloom model and tokenizer with device_map

tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-1B", device_map="auto")
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B")

Load the BLT-1B weights into the model (with strict=False)

model.load_state_dict(model_weights, strict=False)
model.eval() # Put the model in evaluation mode

Input text for inference

input_text = "what is python?" # Replace with your desired input text

Tokenize the input text using the Bloom tokenizer

input_ids = tokenizer(input_text, return_tensors="pt").input_ids

Move input_ids to the same device as the model

input_ids = input_ids.to(model.device)

Generate output with adjusted parameters

with torch.no_grad():
output = model.generate(
input_ids,
max_new_tokens=50,
temperature=0.7,
top_k=50,
top_p=0.95,
repetition_penalty=1.2
)

Decode the output to get the generated text

decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)

Print the generated text

print(decoded_output)

/usr/local/lib/python3.11/dist-packages/huggingface_hub/utils/_auth.py:94: UserWarning:
The secret HF_TOKEN does not exist in your Colab secrets.
To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.
You will be able to reuse this secret in all of your notebooks.
Please note that authentication is recommended but still optional to access public models or datasets.
warnings.warn(
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's attention_mask to obtain reliable results.
Setting pad_token_id to eos_token_id:128001 for open-end generation.
The attention mask is not set and cannot be inferred from input because pad token is same as eos token. As a consequence, you may observe unexpected behavior. Please pass your input's attention_mask to obtain reliable results.
what is python? How to use it?
python 3.6, what are the latest versions of them
I am just starting Python and I have been given a few tasks by my supervisor.
This week we were supposed to make our own web application in Java,

؟؟؟؟؟

Sign up or log in to comment