CyrineElghali commited on
Commit
67434db
Β·
verified Β·
1 Parent(s): ac6fe60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -1,14 +1,18 @@
1
- from transformers import pipeline
2
 
3
- # Load the code generation model (for example, CodeGen or GPT-Neo)
4
- model_name = "deepseek-ai/deepseek-coder-6.7b-instruct" # Example model from Hugging Face
5
- generator = pipeline('text-generation', model=model_name)
 
6
 
7
- # Input description (your task or goal)
8
- text_description = "Create a Python script in Blender to animate a rotating 3D cube."
9
 
10
- # Generate code based on the description
11
- generated_code = generator(text_description, max_length=150)
12
 
13
- # Output the generated code
14
- print(generated_code[0]['generated_text'])
 
 
 
 
1
+ from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
2
 
3
+ # Load tokenizer and model
4
+ model_name = "deepseek-ai/deepseek-coder-6.7b-instruct"
5
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
6
+ model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)
7
 
8
+ # Create a pipeline
9
+ generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
10
 
11
+ # Input description
12
+ text_description = "<|user|>\nCreate a Python script in Blender to animate a rotating 3D cube.\n<|assistant|>"
13
 
14
+ # Generate code
15
+ generated = generator(text_description, max_new_tokens=200, do_sample=True, temperature=0.7)
16
+
17
+ # Print result
18
+ print(generated[0]['generated_text'].replace(text_description, '').strip())