CoolFace
Apppublic

rakesh94m/fraud-investigation-env

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes
App README

Fraud Investigation RL Environment

Overview

This project implements a reinforcement learning environment for financial fraud detection and investigation. It simulates real-world workflows used in banking and payment systems, where agents must make decisions under uncertainty using limited information.

The environment is designed for LLM-based agents to interact, reason, and act through structured observations, actions, and rewards.


Key Features

Real-World Simulation

  • —Simulates financial transactions with realistic fraud patterns
  • —Includes hidden ground truth not visible to the agent
  • —Reflects real-world fraud detection scenarios used in banking systems

Multi-Step Decision Making

Agents must:

  1. 1.Analyze transaction data
  2. 2.Perform investigative actions (history, device, network checks)
  3. 3.Make a final decision (approve, flag, or assess risk)

Hidden Truth Mechanism

  • —The agent cannot directly observe fraud status
  • —Must infer using partial information
  • —Encourages reasoning over rule-based shortcuts

Reward Design

  • —Correct fraud detection: high reward
  • —Correct approval of legitimate transaction: high reward
  • —Investigation actions: moderate reward
  • —Repeated or incorrect actions: low reward

This encourages efficient and intelligent decision-making.


LLM Compatibility

  • —Compatible with OpenAI-style API
  • —Uses environment variables:
  • —APIBASEURL
  • —MODEL_NAME
  • —HF_TOKEN
  • —Includes fallback policy to ensure stability

Tasks

TaskDifficultyDescription
detect_fraudEasyClassify a transaction as fraud or legitimate
assess_riskMediumAssign risk level using transaction context
investigate_chainHardDetect fraud patterns across linked transactions

OpenEnv Compliance

  • —Pydantic-based observation and action models
  • —Implements /reset, /step, /state, /health endpoints
  • —Deterministic grading with bounded score range
  • —Structured interaction loop for agent evaluation

Example Output

[START] task=detectfraud env=fraud-investigation-env model=Qwen/Qwen2.5-72B-Instruct [STEP] step=1 action=flagfraud reward=0.90 done=true error=null [END] success=true steps=1 rewards=0.90


Architecture

  • —engine.py → Environment logic
  • —models.py → Data models
  • —server/app.py → FastAPI server
  • —inference.py → Agent execution
  • —evaluation/ → Graders
  • —Dockerfile → Deployment

Deployment

The environment is deployed on Hugging Face Spaces using Docker. The server runs as an API while inference executes automatically on startup.


Author

Rakesh Meesa