|
import random |
|
import uuid |
|
import json |
|
from transformers import AutoTokenizer, AutoModelForCausalLM |
|
|
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-vision-instruct") |
|
|
|
|
|
config = { |
|
'attn_implementation': 'default' |
|
} |
|
|
|
model = AutoModelForCausalLM.from_pretrained( |
|
"microsoft/Phi-3.5-vision-instruct", |
|
trust_remote_code=True, |
|
**config |
|
) |
|
|
|
|
|
|
|
|
|
|
|
def generate_text(prompt): |
|
inputs = tokenizer(prompt, return_tensors="pt") |
|
outputs = model.generate(inputs['input_ids'], max_length=150) |
|
return tokenizer.decode(outputs[0], skip_special_tokens=True) |
|
|
|
|
|
interest_list = ["networking", "dealMaking"] |
|
personal_interest_list = [ |
|
"Drawing", "Cooking", "Foodie", "Board Gaming", "Card games", "Checkers", "Chess", |
|
"PC gaming", "Puzzle solving", "Video gaming", "Reading", "Science experiments", |
|
"Magic and illusion", "Stand-up comedy", "Walking", "Beer brewing", "Gourmet food exploration", |
|
"Mixology", "Wine tasting" |
|
] |
|
professional_interest_list = [ |
|
"Building a customer-centric culture", "Community Building", "Community Management", |
|
"Delivering exceptional customer service", "Ensuring product/service quality", |
|
"Handling customer complaints and feedback" |
|
] |
|
|
|
|
|
def generate_intelligent_profile(): |
|
|
|
profile = { |
|
"_id": str(uuid.uuid4()), |
|
"latitude": random.uniform(-90, 90), |
|
"longitude": random.uniform(-180, 180), |
|
"interest": random.sample(interest_list, random.randint(1, len(interest_list))), |
|
"personalInterest": random.sample(personal_interest_list, random.randint(3, 7)), |
|
"professionalInterest": random.sample(professional_interest_list, random.randint(3, 5)) |
|
} |
|
|
|
|
|
education_prompt = "Generate an educational background for a professional profile with relevant qualifications." |
|
profile["educationalDetails"] = [generate_text(education_prompt)] |
|
|
|
|
|
professional_prompt = "Generate a professional career summary for a profile with achievements and roles." |
|
profile["professionalDetails"] = [generate_text(professional_prompt)] |
|
|
|
return profile |
|
|
|
|
|
def generate_profiles(num_profiles=5): |
|
profiles = [generate_intelligent_profile() for _ in range(num_profiles)] |
|
return {"data": profiles} |
|
|
|
|
|
generated_profiles = generate_profiles(3) |
|
print(json.dumps(generated_profiles, indent=4)) |
|
|