token-counting-and-output
Count tokens consumed during data retrieval operations, validate numeric format, and write results to /root/answer.json with proper structure.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- token-counting-and-output
- description
- Count tokens consumed during data retrieval operations, validate numeric format, and write results to /root/answer.json with proper structure.
03 SKILL.md 正文
Token Counting and Output Skill
Step 1: Initialize Token Counter
- Create a counter starting at 0 for each question
- Track tokens consumed by:
- File I/O operations (reading question file, data files)
- Data parsing and searching operations
- Evidence extraction and traversal
- Deduplication and formatting
Step 2: Accumulate Tokens Per Question
For each question:
- Add tokens for artifact retrieval
- Add tokens for evidence tier extraction (Tier 1, 2, 3)
- Add tokens for multi-hop traversal (per hop)
- Store as numeric value (int or float), NOT as string
Step 3: Validate Answer Lists
Before finalizing:
- Verify every answer is stored as a list, never a string
- If answer contains one item, list has length 1:
["item"] - If answer contains multiple items, all in one list:
["item1", "item2", "item3"] - If answer is empty, use empty list:
[]
Step 4: Validate Token Format
- Ensure
tokensfield is numeric type (int or float) - Never store tokens as
"123"(quoted string) - Always store as
123(unquoted number)
Step 5: Build Output JSON Structure
{
"q1": {
"answer": ["name1", "name2"], # Always a list
"tokens": 150 # Always numeric, never string
},
"q2": {
"answer": ["single_name"], # Single item still in list
"tokens": 200
},
"q3": {
"answer": [], # Empty if no answer found
"tokens": 100
}
}
Step 6: Write to File
- Write to
/root/answer.json - Use
json.dumps()with proper formatting - Ensure the file is valid JSON that can be parsed by
json.load()in Python - Verify file is readable and contains expected structure
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.