zainimam commited on
Commit
3330fc9
·
verified ·
1 Parent(s): 4670177

created main.py

Browse files
Files changed (1) hide show
  1. main.py +21 -0
main.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+
4
+ # Load the tokenizer and model from Hugging Face
5
+ model_name = "impactframes/molmo-7B-D-bnb-4bit"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name)
8
+
9
+ # Example input prompt
10
+ prompt = "What is the meaning of life?"
11
+
12
+ # Tokenize the input
13
+ inputs = tokenizer(prompt, return_tensors="pt")
14
+
15
+ # Generate output
16
+ with torch.no_grad():
17
+ outputs = model.generate(inputs.input_ids, max_length=100)
18
+
19
+ # Decode the output
20
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
21
+ print(response)