deeppersona-experience / METHOD_COMPARISON.md
Yufan_Zhou
Update UI: improve spacing, font sizes, layout and add life story and interests fields
40c05c4

A newer version of the Gradio SDK is available: 6.9.0

Upgrade

Generation Method Comparison

Overview

This document compares the original generation method (generation_user_profile) with the improved method (generate_user_profile_final).

Architecture Comparison

Original Method (generation_user_profile)

Input β†’ generate_profile.py β†’ Batch attribute generation β†’ Final summary

Key characteristics:

  • Single-pass batch generation for all attributes
  • Generic prompts for all attribute types
  • Fixed attribute selection
  • Simpler summary generation

Improved Method (generate_user_profile_final)

Input β†’ select_attributes.py β†’ Category-based generation β†’ Enhanced summary
         ↓
    Configurable attribute count
         ↓
    Sequential category processing with context building

Key characteristics:

  • Multi-stage generation with context accumulation
  • Category-specific prompts with detailed instructions
  • Configurable attribute count (100-350)
  • Advanced summary generation with "Show, Don't Tell" principle

Detailed Comparison

1. Attribute Selection

Aspect Original Improved
Selection Method Fixed selection Dynamic based on count
Configurability No Yes (100-350 attributes)
Diversity Standard Adaptive

2. Generation Prompts

Original Method - Generic Prompt

system_prompt = """You are an AI assistant specialized in generating 
attribute values for personal profiles. Based on the provided base summary 
and multiple attribute paths, generate logically consistent values..."""

Improved Method - Category-Specific Prompts

Example: Demographic Information

demographic_input = """
Instructions: Based on the `base_info` and `life_story` provided, 
**develop and elaborate on** the 'Demographic Information' section in English. 
Your task is to **appropriately expand upon and enrich** the existing information 
from `base_info` and incorporate relevant insights from the `life_story`...
"""

Example: Core Values

core_input = """
Instructions: Based on the full context provided, develop and elaborate on 
the 'Core Values, Beliefs, and Philosophy' section in English. 
Pay special attention to the person's location and background, 
infusing the philosophical outlook with relevant cultural nuances...
IMPORTANT: Avoid including anything related to community-building activities.
Prohibit the use of words such as 'balance' and 'balance'
"""

3. Generation Flow

Original Method

1. Run select_attributes.py
2. Load base_info and selected_paths
3. Generate all sections in parallel:
   - Demographic Information
   - Career and Work Identity
   - Core Values, Beliefs, and Philosophy
   - Lifestyle and Daily Routine
   - Cultural and Social Context
   - Hobbies, Interests, and Lifestyle
   - Other Attributes
4. Generate summary

Improved Method

1. Run select_attributes.py with specified attribute count
2. Load base_info and selected_paths
3. Generate sections sequentially with context building:
   Step 1: Demographic Information
           ↓ (context passed forward)
   Step 2: Career and Work Identity
           ↓ (accumulated context)
   Step 3: Core Values, Beliefs, and Philosophy
           ↓ (accumulated context)
   Step 4: Lifestyle and Daily Routine
           ↓ (accumulated context)
   Step 5: Cultural and Social Context
           ↓ (accumulated context)
   Step 6: Hobbies, Interests, and Lifestyle
           ↓ (accumulated context)
   Step 7: Other Attributes
           ↓
4. Generate enhanced summary with full context

4. Summary Generation

Original Method

system_prompt = """
Your Task: Create a believable and engaging personal profile, 
150-400 words, based on the provided text. Your ultimate goal is 
a narrative that feels like it comes from a real, self-aware person.
"""

Improved Method

system_prompt = """
Your task: Based solely on the provided user attributes and personal story, 
create an objective and factual personal profile, strictly between 150–400 words.

Content Requirements:
β€’ The profile must be written entirely in the first-person perspective.
β€’ The output should be a coherent, logically structured narrative, not a list of points.
β€’ The opening must explicitly state my country or region.
β€’ Must include:
  1. Basic background (e.g., location, identity)
  2. Daily life or work routines
  3. Personal interests and hobbies (explicitly highlighted)
  4. Behavioral tendencies or values (positive or negative)
β€’ Interests and hobbies must be integrated naturally with small, ordinary details.
β€’ If there are negative traits, they must be represented faithfully without softening.
β€’ No declarative or reflective endings.
β€’ Only include information explicitly provided.
β€’ Prohibit the use of words such as 'balance' and 'balance'
"""

user_prompt += """
Generate a first-person narrative of 100-400 words from the provided profile. 
Your primary goal is to make the person feel real, believable, and authentic.

To achieve this, strictly follow the 'Show, Don't Tell' principle:
1. **Illustrate, Don't Declare:** Show values and traits through specific actions.
2. **Connect Actions to Motivation:** Briefly explain the 'why' behind key choices.
3. **Maintain a Natural Voice:** The tone must be sincere and grounded.
"""

5. Context Management

Aspect Original Improved
Context Passing Minimal Comprehensive
Section Dependencies Independent Sequential with accumulation
Consistency Enforcement Basic Advanced with explicit instructions

6. Quality Control

Original Method

  • Basic word count check (150-400 words)
  • JSON parsing validation
  • Simple error handling

Improved Method

  • Strict word count enforcement (100-400 words)
  • Enhanced JSON parsing with markdown cleanup
  • Detailed error reporting with traceback
  • Category-specific validation
  • Explicit prohibition of certain words/phrases
  • "Show, Don't Tell" principle enforcement

7. Hobbies and Interests Generation

Original Method

hobbies_input = """
Based on the complete profile context provided above, generate the 
'Hobbies, Interests, and Lifestyle' section.

1. Use Base Hobbies as a Starting Point
2. Embrace Imagination and Psychological Depth
3. Synthesize with Full Context
4. Detail Related Lifestyle Choices
"""

Improved Method

hobbies_input = """
Ensure that all hobbies, interests, and lifestyle choices presented are:
1. **Firmly anchored to and primarily derived from the hobbies indicated 
   in `base_info` and experiences from `life_story`.**
2. Logically consistent with all provided information.
3. Enriched by supplementary information where appropriate, without 
   overshadowing the core hobbies from `base_info`.
**Do not introduce new primary hobbies or interests that are not clearly 
supported by or cannot be reasonably inferred from the `base_info` and 
`life_story` themselves.**
Prohibit the use of words such as 'balance' and 'balance'
"""

Performance Comparison

Metric Original Improved
Generation Time ~2-3 min ~3-5 min (due to sequential processing)
API Calls ~7-8 ~7-8
Consistency Good Excellent
Realism Good Excellent
Customization Limited High

Use Case Recommendations

Use Original Method When:

  • Quick generation is needed
  • Standard attribute set is sufficient
  • Simple personas are acceptable

Use Improved Method When:

  • High-quality, realistic personas are required
  • Detailed character profiles are needed
  • Consistency across attributes is critical
  • Custom attribute counts are desired
  • Cultural nuances are important

Code Examples

Original Method Usage

from generation_user_profile.code.web_api_bridge import generate_profile_from_input

input_data = {
    "basic_info": {
        "age": 30,
        "gender": "Female",
        "occupation": {"status": "Software Engineer"},
        "location": {"city": "San Francisco", "country": "USA"}
    }
}

profile = generate_profile_from_input(input_data)
print(profile["Summary"])

Improved Method Usage

from generate_user_profile_final.code.web_api_bridge import generate_profile_from_input

input_data = {
    "basic_info": {
        "age": 30,
        "gender": "Female",
        "occupation": {"status": "Software Engineer"},
        "location": {"city": "San Francisco", "country": "USA"}
    }
}

# Generate with 250 attributes for more detail
profile = generate_profile_from_input(input_data, attribute_count=250)
print(profile["Summary"])

# Access detailed sections
print(profile["Demographic Information"])
print(profile["Career and Work Identity"])
print(profile["Hobbies, Interests, and Lifestyle"])

Conclusion

The improved method (generate_user_profile_final) offers:

  • Better Quality: More realistic and authentic personas
  • More Control: Configurable attribute counts
  • Higher Consistency: Sequential generation with context building
  • Enhanced Realism: Advanced prompts with specific guidelines

Trade-offs:

  • Slightly Slower: Sequential processing takes more time
  • More Complex: More sophisticated logic and error handling

For production use cases requiring high-quality persona generation, the improved method is recommended.