BrainAPI
BrainAPI
Retrieve

For the complete BrainAPI documentation index, see llms.txt. A markdown version of any docs page is available by appending .md to its URL. Docs MCP: /docs/mcp.

Recommendations

Train-free graph recommendations around a target entity or user

GET|POST /retrieve/recommend ranks item nodes connected to a target through the event graph. It is a recommendation surface, not a text-search endpoint: callers provide a target entity/user instead of a query.

For agents

  • Required: target; default top_k=20, range 1…200
  • Use GET for common controls and POST for custom behavior_weights
  • Returns graph nodes, scores, contributing nodes, and a recommendation channel
  • Evaluate next-item behavior with RecSys metrics, never Search nDCG

Search versus Recommendations

SearchRecommendations
InputQuery text, optional user targetTarget node/user
First stageBM25/dense/plugin/graph retrievalEvent-graph walks and affinities
OutputPassage or node hitsItem nodes
PersonalizationQuery-gated rerank of retrieved node_idsTarget affinity is the primary task
BenchmarkRecall/nDCG/MRRHitRate/Recall@K

Usage

curl --get "<DEPLOYMENT_URL>/retrieve/recommend" \
  -H "BrainPAT: YOUR_BRAIN_PAT" \
  -H "X-Brain-ID: commerce" \
  --data-urlencode "target=user:u01" \
  --data-urlencode "top_k=20" \
  --data-urlencode "include_attribute_pref=true" \
  --data-urlencode "exclude_seen=true"

Request reference

FieldTypeDefaultMeaning
targetstringrequiredTarget node UUID or resolvable identifier.
polaritysame | oppositesameMatch or invert candidate polarity.
top_kinteger20Return count, 1 through 200.
labelsstring[]unsetCandidate node-label filter.
include_asymmetricbooleantrueInclude complementary directional walks.
include_multi_interestbooleantrueCombine multiple interest regions.
include_attribute_prefbooleanfalseScore shared attribute hubs.
diversifybooleantrueAvoid a near-duplicate-only list.
asymmetric_directionoutbound | inbound | bothoutboundDirection for asymmetric evidence.
exclude_seenbooleanfalseRemove items already connected through observed behavior.
recency_half_life_daysnumberunsetOptional non-negative decay half-life.
dampen_degreebooleanfalseReduce high-degree popularity effects.
behavior_weightsobjectunsetPOST only; per-behavior weight overrides.

Behavior weights

The built-in table treats stronger intent as more evidence:

Behavior aliasesDefault weight
view, click, unknown behavior0.2
cart, add_to_cart, follow0.5
favorite, favourite, wishlist0.7
purchase, buy, bought1.0

Aliases are normalized across capitalization, spaces, dashes, and underscores. POST can supply a custom behavior_weights map without changing server-wide defaults.

Response

{
  "target_node": {"uuid": "user:u01", "labels": ["USER"], "name": "u01"},
  "recommendations": [
    {
      "node": {"uuid": "sku-42", "labels": ["PRODUCT"], "name": "Oak table"},
      "score": 0.84,
      "connected_by": [{"uuid": "event-7", "labels": ["EVENT"], "name": "Purchase"}],
      "channel": "asymmetric"
    }
  ]
}

Channel names describe the graph mechanism that contributed the item. They are not Search channels and should not be fused with Search metrics.

Edit on GitHub

Last updated on

On this page