Find organization axes

This recipe shows you how to discover the best dimensions for organizing your videos and images. The response includes ranked categorization strategies with effectiveness scores, expected groups, and example categories, ready for data-driven organization decisions.

Use cases:

  • New collection exploration: Discover natural groupings in videos and images you haven’t categorized yet
  • Strategy comparison: Evaluate categorization approaches side by side before committing to a taxonomy
  • Organization pipeline: Feed scored axes into a workflow that categorizes every item

Key concepts

  • Knowledge store: A persistent store of your videos and images plus the understanding the platform derives from them — spatiotemporal context, a typed ontology, and embeddings — that together enable corpus-level reasoning.
  • Instructions: Additional guidance that shapes Jockey’s behavior for a specific domain or task.
  • Structured output: A JSON schema you provide with your request. Jockey constrains its output to match your schema, so you retrieve machine-readable results instead of plain text. For a guide on designing schemas and parsing responses, see the Structured output page.

Workflow

This recipe combines three elements: a JSON schema that defines the axis data structure, instructions that give Jockey a specific role and domain guidance, and a prompt that describes what you want evaluated. Jockey reasons across your knowledge store, evaluates possible categorization strategies, and returns ranked results with effectiveness scores. You can adapt this recipe to evaluate different domains or apply different ranking criteria.

Prerequisites

  • You’ve already created a knowledge store with at least one item in ready status. See the Quickstart page for details.
  • You’re familiar with the request and response format. See the Create a response page for details.

Complete example

Copy and paste the code below, replacing the placeholders surrounded by <> with your values.

1import json
2from twelvelabs import TwelveLabs, TextParam
3from twelvelabs.types.text_param_format import TextParamFormat_JsonSchema
4
5client = TwelveLabs(api_key="<YOUR_API_KEY>")
6STORE_ID = "<YOUR_KNOWLEDGE_STORE_ID>"
7
8# Define a JSON schema for the organization axes
9axes_schema = {
10 "type": "object",
11 "properties": {
12 "axes": {
13 "type": "array",
14 "items": {
15 "type": "object",
16 "properties": {
17 "axis": {"type": "string"}, # Name of the categorization dimension
18 "description": {"type": "string"}, # What this axis measures or captures
19 "expected_groups": {"type": "integer"}, # Estimated number of categories
20 "example_categories": { # Sample category names
21 "type": "array",
22 "items": {"type": "string"},
23 },
24 "effectiveness_score": {"type": "number"}, # 0-1 score for separation quality
25 "rationale": {"type": "string"}, # Why this axis works well (or not)
26 },
27 },
28 },
29 "recommendation": {"type": "string"}, # Overall best-strategy recommendation
30 },
31}
32
33# Rank the organization strategies
34response = client.responses.create(
35 knowledge_store_id=STORE_ID,
36 instructions="You are a content strategist. Analyze these videos and images and recommend the most effective ways to organize it. Score each axis by how well it separates content into distinct, useful groups.",
37 input=[{"type": "message", "role": "user", "content": "What are the top 5 best ways to organize these videos and images? Score each from 0-1 based on how cleanly it separates the content."}],
38 text=TextParam(format=TextParamFormat_JsonSchema(name="organization_axes", schema_=axes_schema)),
39)
40
41# Parse and read the strategies
42for output in response.output:
43 if output.type == "message":
44 for content in output.content:
45 data = json.loads(content.text)
46 print(f"Recommendation: {data['recommendation']}\n")
47 for ax in data["axes"]:
48 print(f" {ax['axis']} (score: {ax['effectiveness_score']})")
49 print(f" {ax['description']}")
50 print(f" Groups: {ax['expected_groups']} - {', '.join(ax['example_categories'])}")
51 print(f" Why: {ax['rationale']}\n")

Code explanation

To rank organization strategies, call the responses.create method with instructions, a prompt, and a text parameter that describes your result schema.
Parameters:

  • knowledge_store_id: The unique identifier of the knowledge store to reason over.
  • input: An array of input items. Each item is a message you send to Jockey. This example asks Jockey to recommend the top five categorization strategies and score each on a 0–1 scale.
  • instructions: A per-request system prompt that shapes Jockey’s behavior for a domain or task. This example uses a content strategist role that evaluates categorization strategies.
  • text: An object that specifies the response format. To return structured JSON, set the format field: its schema_ field defines the structure the output must match, and its name field identifies the schema. Design the schema to fit your use case; the inline comments in the example describe each field. For the schema rules, see the Structured output page.

Return value: An object of type ResponseObject containing, among other information, the following fields:

  • id: The unique identifier of the response.
  • knowledge_store_id: The knowledge store this response was generated against.
  • session_id: The session identifier. Pass it in a follow-up request to continue the conversation.
  • status: The status of the response. The possible values are completed, failed, in_progress, and incomplete.
  • output: The response output items. The text field of each content part in a message item is a JSON string that matches your schema. Parse it with json.loads(), then iterate the axes array to read each ranked strategy.
  • usage: Token usage statistics, including the input_tokens and output_tokens fields.

Example response

The text field inside each content part is a JSON string that matches your schema. After parsing, a typical result looks like this:

1{
2 "axes": [
3 {
4 "axis": "Content Type",
5 "description": "Groups videos by their format and production style",
6 "expected_groups": 4,
7 "example_categories": ["tutorials", "product demos", "interviews", "presentations"],
8 "effectiveness_score": 0.92,
9 "rationale": "Each video clearly fits one format, producing well-separated groups with minimal overlap"
10 },
11 {
12 "axis": "Product Area",
13 "description": "Groups videos by the feature or product they cover",
14 "expected_groups": 5,
15 "example_categories": ["analytics dashboard", "API platform", "mobile SDK", "integrations", "billing"],
16 "effectiveness_score": 0.85,
17 "rationale": "Videos focus on specific product areas, creating meaningful clusters for feature-based navigation"
18 },
19 {
20 "axis": "Target Audience",
21 "description": "Groups videos by the intended viewer",
22 "expected_groups": 3,
23 "example_categories": ["developers", "product managers", "executives"],
24 "effectiveness_score": 0.78,
25 "rationale": "Most videos target a clear audience, though some span multiple groups"
26 },
27 {
28 "axis": "Difficulty Level",
29 "description": "Groups videos by the assumed prior knowledge of the viewer",
30 "expected_groups": 3,
31 "example_categories": ["beginner", "intermediate", "advanced"],
32 "effectiveness_score": 0.71,
33 "rationale": "Difficulty is readable across most content but some videos mix levels within a single session"
34 },
35 {
36 "axis": "Recency",
37 "description": "Groups videos by when they were produced relative to product releases",
38 "expected_groups": 4,
39 "example_categories": ["pre-launch", "launch week", "post-launch", "evergreen"],
40 "effectiveness_score": 0.63,
41 "rationale": "Useful for filtering out outdated content but requires timestamp metadata to apply reliably"
42 }
43 ],
44 "recommendation": "Content Type produces the cleanest separation. Combine with Product Area as a secondary axis for a two-level taxonomy."
45}
Note

Jockey evaluates each axis against the actual content in your knowledge store. Scores and recommendations change depending on the videos you have indexed.

Variations

Change the instructions and prompt to adapt this recipe for different organizational needs.

  • Domain-constrained: Set the instructions parameter to a team-specific perspective: “marketing strategist,” “education specialist,” or “compliance officer.”
  • Audience-centric: Change the prompt to “How would different audiences want these videos and images organized?”
  • Hierarchical taxonomy: Change the prompt to “Suggest a two-level taxonomy: primary axes and sub-axes for each.”

Jupyter notebook

Open In Colab

See also