Skip to main content
Loading navigation
Back to prompt library

Build a FollowTheMoney Entity Search Re-ranker — implementation

Linked challenge: Build a FollowTheMoney Entity Search Re-ranker

Prompt source

implementation104 lines11 sectionsNo variables1 code block
## Build
Intercept search queries to a local yente API appliance and apply secondary re-ranking based on custom risk criteria. Elevate PEP and sanctions entities above generic watchlist hits using a proxy layer.

## User
Compliance Systems Engineer

## Workflow
1. Receive standardized HTTP search queries intended for the yente match endpoint.
2. Forward queries to local yente instance and parse the returned FollowTheMoney entity array.
3. Re-rank the results by extracting and scoring risk tags like PEP or sanctions presence.
4. Return the re-ordered entity list in the native yente JSON response format.

## Interface
A developer testing harness showing original yente ranking versus the adjusted risk-weighted re-ranking.

## Data
Execute queries against a local yente instance loaded with OpenSanctions default datasets.
Starter examples below are synthetic. They are not downloaded records.

## Source
[OpenSanctions data toolkit](https://raw.githubusercontent.com/opensanctions/yente/main/README.md)
Leverage FollowTheMoney entity schemas and OpenSanctions match endpoints supported by yente.

## Tools
pydantic-ai, fastapi, httpx.
Pydantic AI provides robust structured parsing for validating intercepted queries and dynamically scoring entity risk attributes.
LLM capable of structured evaluation to identify implicit risk signals in entity text fields and rank matches.

## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.

## Acceptance
- Successfully intercepts and forwards queries to a local yente backend.
- Identifies and elevates entities flagged with specific risk topics (e.g., sanction).
- Outputs the modified result array maintaining strict yente HTTP response schema compatibility.

## Starter Examples
```json
[
  {
    "input": {
      "query_params": {
        "q": "John Smith"
      },
      "original_yente_response": {
        "results": [
          {
            "id": "1",
            "topics": [
              "crime"
            ]
          },
          {
            "id": "2",
            "topics": [
              "sanction"
            ]
          }
        ]
      }
    },
    "expected_output": {
      "reordered_results": [
        {
          "id": "2",
          "topics": [
            "sanction"
          ],
          "rank_boost": true
        },
        {
          "id": "1",
          "topics": [
            "crime"
          ],
          "rank_boost": false
        }
      ],
      "status": "success",
      "note": "simplified synthetic app records, not complete official schema files."
    }
  },
  {
    "input": {
      "query_params": {
        "q": "ACME Corp"
      },
      "original_yente_response": {
        "results": [
          {
            "id": "3",
            "topics": []
          }
        ]
      }
    },
    "expected_output": {
      "reordered_results": [
        {
          "id": "3",
          "topics": [],
          "rank_boost": false
        }
      ],
      "status": "success",
      "note": "simplified synthetic app records, not complete official schema files."
    }
  }
]
```

## Safety
Operates on mock compliance search logs and public OpenSanctions data without automated enforcement.
Use mock external writes. Require human review before any real deployment.