Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -361,6 +361,10 @@ def create_cluster_dataframes(processed_df):
|
|
361 |
from transformers import GPTNeoForCausalLM, GPT2Tokenizer
|
362 |
def generate_project_proposal(problem_descriptions, location, problem_domain):
|
363 |
print("Trying to access gpt-neo-1.3B")
|
|
|
|
|
|
|
|
|
364 |
model = GPTNeoForCausalLM.from_pretrained("EleutherAI/gpt-neo-1.3B")
|
365 |
tokenizer = GPT2Tokenizer.from_pretrained("EleutherAI/gpt-neo-1.3B")
|
366 |
|
@@ -371,17 +375,32 @@ def generate_project_proposal(problem_descriptions, location, problem_domain):
|
|
371 |
prompt = f"Generate a solution oriented project proposal for the following:\n\nLocation: {location}\nProblem Domain: {problem_domain}\nProblems: {problems_summary}\n\nProject Proposal:"
|
372 |
|
373 |
# Generate the proposal
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
|
386 |
def create_project_proposals(budget_cluster_df, problem_cluster_df, location_clusters, problem_clusters):
|
387 |
print("\n Starting function: create_project_proposals")
|
|
|
361 |
from transformers import GPTNeoForCausalLM, GPT2Tokenizer
|
362 |
def generate_project_proposal(problem_descriptions, location, problem_domain):
|
363 |
print("Trying to access gpt-neo-1.3B")
|
364 |
+
print("problem_descriptions: ", problem_descriptions)
|
365 |
+
print("location: ", location)
|
366 |
+
print("problem_domain: ", problem_domain)
|
367 |
+
|
368 |
model = GPTNeoForCausalLM.from_pretrained("EleutherAI/gpt-neo-1.3B")
|
369 |
tokenizer = GPT2Tokenizer.from_pretrained("EleutherAI/gpt-neo-1.3B")
|
370 |
|
|
|
375 |
prompt = f"Generate a solution oriented project proposal for the following:\n\nLocation: {location}\nProblem Domain: {problem_domain}\nProblems: {problems_summary}\n\nProject Proposal:"
|
376 |
|
377 |
# Generate the proposal
|
378 |
+
try:
|
379 |
+
input_ids = tokenizer.encode(prompt, return_tensors="pt")
|
380 |
+
print("Input IDs shape:", input_ids.shape)
|
381 |
+
output = model.generate(
|
382 |
+
input_ids,
|
383 |
+
max_length=300,
|
384 |
+
num_return_sequences=1,
|
385 |
+
no_repeat_ngram_size=2,
|
386 |
+
temperature=0.75)
|
387 |
+
print("Output shape:", output.shape)
|
388 |
+
proposal = tokenizer.decode(output[0], skip_special_tokens=True)
|
389 |
+
print("Successfully accessed gpt-neo-1.3B and returning")
|
390 |
+
return proposal
|
391 |
+
except Exception as e:
|
392 |
+
print("Error generating proposal:", str(e))
|
393 |
+
return prompt
|
394 |
+
|
395 |
+
|
396 |
+
|
397 |
+
|
398 |
+
|
399 |
+
|
400 |
+
|
401 |
+
|
402 |
+
|
403 |
+
|
404 |
|
405 |
def create_project_proposals(budget_cluster_df, problem_cluster_df, location_clusters, problem_clusters):
|
406 |
print("\n Starting function: create_project_proposals")
|