tm23hgf/social-network-env
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Hugging Face Space: https://huggingface.co/spaces/tm23hgf/social-network-env Core Env Logic: https://huggingface.co/spaces/tm23hgf/social-network-env/tree/main/socialnetworkenv
Github Link: https://github.com/TM23-sanji/socialnetwork Colab Link: https://colab.research.google.com/drive/1AXF0PdRhgbH63VP-AuziA9jL93z38Yh#scrollTo=74s-CR4kYpV9
InfoNet: Adversarial Social Network Detection Environment
1. Concept & Overview
InfoNet is a synthetic adversarial social network simulation where a detection agent learns to identify coordinated inauthentic behavior (propagandists) using only observable behavioral signals. The detector never sees ground-truth account roles, never sees content truth labels, and cannot rely on simple fact-checking.
The simulation runs 150 steps per episode. Every 5 steps, the detector reviews the network state and decides which accounts to flag. Propagandists adapt — changing topics and personas after being flagged — creating an adversarial co-training loop.
2. Agent Architecture
Agent Roster (10 Total)
Design Rationale: Clean Role Separation
- Propagandists do not cite. If they did, they would look like amplifiers. The detector learns coordination patterns (who gets cited by whom), not role labels.
- Neutrals do not cite. Clean separation means the detector learns timing and repetition patterns.
- Amplifiers are the only citers. The detector doesn't know who they are citing until it sees the pattern.
3. Content Model
Every post has three attributes:
Key Design: True Facts + Framing
Propagandists use verifiably true facts with fear/outrage framing. The detector cannot win by keyword matching or truth detection — it must learn behavioral coordination.
4. Episode Mechanics
Episode Parameters
Simulation Loop
for step in 1..150:
graph.step = step
# Every agent acts (simultaneously)
actions = _collect_actions() # Neutral posts, Amplifier cites, Propagandist posts/reacts
_execute_actions(actions) # Add posts to graph, process amplifier assignments
# Every 5 steps: detector reviews
if step % 5 == 0:
observation = build_observation()
flagged = detector_llm(observation) OR fallback_policy()
flagged = flagged[:2] # Cap at 2 flags
for acc in flagged:
graph.flag_account(acc, step)
reward_computer.compute_review_reward()5. Agent Detail
NeutralAgent (5 accounts)
- Posts from a neutral data pool at Poisson rates (0.30–0.45 per step depending on persona)
- Personas:
hothead,careful_journalist,clickbait,partisan,rando - Framing varies by persona (e.g.,
hothead→ outrage/anger/fear dominant) - Posts from 301 topics, all topic-focused (no off-topic personal content)
AmplifierAgent (3 accounts)
- Auto-recruited by propagandists when they post
- Queued assignments:
(prop_id, target_step, post_id) - At
target_step, cites the propagandist's post - Falls back to citing neutral posts (80% chance) when no assignments mature
- Not the primary detection target — amplifier citations help trace back to source
PropagandistAgent (2 accounts)
- Has
current_topic+angle_idx(0 or 1) +mimic_persona - Posts from the propaganda bank (301 topics × 2 angles × 5 personas)
- 50% posting probability per step when not flagged
- When flagged (after 3-step delay), LLM decides action:
MIMIC(persona="hothead")— adopt new persona, flip anglePIVOT(topic="Climate_Change")— switch topic, flip angleBURN— quit immediately (goes silent forever)WAIT— do nothing
6. Propaganda Bank
Location: data/episodes/propaganda_bank/
{Topic}/
angle_0/{hothead|clickbait|partisan|rando|careful_journalist}.jsonl
angle_1/{...}- 301 topics × 2 angles × 5 personas × 30 samples = ~90,300 samples
- Content: Neutral posts rewritten through angle-specific lens
- Angle 0 "managed_stability": Institutions/experts handling it; critics are alarmist
- Angle 1 "progressandstewardship": Markets/innovation solving problems; intervention causes harm
7. Detector Mechanics
Observation Format
At each review, the detector sees:
STEP 30 REVIEW OBSERVATION
============================================================
EPISODE SUMMARY:
- Steps completed: 30/150
- Total posts: 156
- Total citations: 77
- Total flagged accounts: 4
- Burned accounts: 0
SUSPICION TRACKER (all accounts):
Account_1: rate=0.40, posts=13, cited=0, status=FLAGGED/ACTIVE
Account_2: rate=1.00, posts=26, cited=26, status=FLAGGED/ACTIVE
...
RECENT ACTIVITY (last 8 steps = steps 23-30):
Step 23: Account_1 POSTED [Cyber_Law] "Catch-22; stronger laws needed..."
Step 23: Account_2 CITED (cites Account_10's post from step 19)
...
YOUR PREVIOUS FLAGS:
- Step 15: Flagged Account_9
- Step 20: Flagged Account_3
...
DECIDE: Flag up to 2 accounts, or WAIT.Key insight: The detector sees the effects of PIVOT/MIMIC (topic changes, citation pattern shifts) but never sees the action JSON itself.
Output Schema
{
"reasoning": "Account_1 and Account_9 consistently cite posts from Account_2, which was flagged in previous steps. This suggests coordinated amplification...",
"flags": [
{"account_id": 1, "confidence": 0.85},
{"account_id": 9, "confidence": 0.72}
]
}Parsing: If JSON parsing fails, fallback to empty flags (WAIT). The episode continues.
8. Reward Structure
Single training phase (no curriculum). All episodes use the same rewards.
Per-Review Reward
Active Propagandan Definition
An active propagandistan is one that:
- Posted within the last 5 steps, AND
- Was not flagged in the current review
F1 Metrics
Only propagandists are the positive class (amplifiers are FPs):
Precision = TP_prop / (TP_prop + FP_all)
Recall = TP_prop / (TP_prop + FN_prop)
F1 = 2 × Precision × Recall / (Precision + Recall)9. Episode Output Files
ep_{NNNN}/
├── metadata.json # Ground truth, reward summary, F1 metrics, final flags
├── final_state.json # Full graph state including pivot log
├── detector_traces.jsonl # SFT data: observation → {reasoning, flags}
└── propagandist_traces.jsonl # Prop traces: prompt → {action, params, reasoning}10. SFT Training Data
Only the detector is trained via SFT.
Format
System: You are a social network analyst tasked with detecting coordinated inauthentic behavior...
User (Observation):
<full observation text>
Assistant (Expected Output):
{"reasoning": "...", "flags": [{"account_id": 1, "confidence": 0.85}, ...]}Current Data Quality
- 150 detector traces (5 episodes × 30 reviews each)
- 100% have valid JSON with proper structure
- 100% have chain-of-thought reasoning (avg 50+ words, min 27 words)
- Structure:
{"reasoning": str, "flags": [{"account_id": int, "confidence": float}]}
Planned Scale
- Run 600 episodes with 3B model
- Filter later based on quality metrics
- All traces must have valid JSON with
reasoningandflagsfields
11. Key Constants
12. File Structure
infonet/
├── data/
│ ├── neutral_data_pool/
│ │ ├── config.json # 301 topics
│ │ └── generated/ # 5 personas × 301 topics JSONL files
│ ├── episodes/
│ │ ├── src/ # Simulation engine
│ │ │ ├── agents.py # NeutralAgent, AmplifierAgent, PropagandistAgent
│ │ │ ├── config.py # All constants
│ │ │ ├── episode.py # EpisodeRunner — main loop
│ │ │ ├── graph.py # GraphStateManager — central state
│ │ │ ├── observation.py # ObservationBuilder — detector input
│ │ │ ├── prompts.py # System prompts
│ │ │ ├── rewards.py # RewardComputer
│ │ │ ├── schemas.py # Pydantic models
│ │ │ ├── vllm_client.py # LLM client with retry
│ │ │ └── detector.py # Fallback policies
│ │ ├── episode_pool/ # Generated episodes
│ │ │ └── ep_{NNNN}/
│ │ ├── propaganda_bank/ # 301 topics × 2 angles × 5 personas
│ │ └── generate_episodes.py # CLI entry point
├── README.md
└── requirements.txt13. What Was Removed / Changed
14. How Agents Interact
Propagandistan posts
↓
Propagandan auto-recruits 2 amplifiers
↓
Amplifiers queued with delay
↓
Amplifiers cite at target step
↓
Detector reviews every 5 steps
↓
Detector flags suspicious accounts
↓
Propagandan sees flag after 3-step delay
↓
Propagandan LLM reacts: MIMIC/PIVOT/BURN/WAIT
↓
Topic/persona changes → new coordination patterns
↓
Detector observes behavioral changes15. Current Status
- Episode generation: Working (3B model via vLLM)
- Reward structure: Finalized
- SFT data: 150 traces from 5 episodes
- Scale-up: Ready for 600 episodes
- Training pipeline: Not yet implemented
Document version: 2.0 Last updated: After implementation consolidation
