Spaces:
Running
Running
acecalisto3
commited on
Commit
•
897dd01
1
Parent(s):
69a5d61
Update code_generator.py
Browse files- code_generator.py +8 -3
code_generator.py
CHANGED
@@ -2,17 +2,22 @@ import transformers
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
def generate(idea):
|
5 |
-
"""Generates code based on a given idea using the
|
6 |
|
7 |
Args:
|
8 |
idea: The idea for the code to be generated.
|
9 |
|
10 |
-
|
11 |
The generated code as a string.
|
12 |
"""
|
13 |
-
|
|
|
|
|
|
|
14 |
tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
|
15 |
|
|
|
|
|
16 |
# Generate the code
|
17 |
input_text = f"""
|
18 |
# Idea: {idea}
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
def generate(idea):
|
5 |
+
"""Generates code based on a given idea using the bigscience/T0_3B model.
|
6 |
|
7 |
Args:
|
8 |
idea: The idea for the code to be generated.
|
9 |
|
10 |
+
Returns:
|
11 |
The generated code as a string.
|
12 |
"""
|
13 |
+
|
14 |
+
# Load the code generation model
|
15 |
+
model_name = "bigscience/T0_3B" # Use a model that works for code generation
|
16 |
+
model = transformers.AutoModelForCausalLM.from_pretrained(model_name)
|
17 |
tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
|
18 |
|
19 |
+
# Generate the code
|
20 |
+
|
21 |
# Generate the code
|
22 |
input_text = f"""
|
23 |
# Idea: {idea}
|