{"id":25676948,"url":"https://github.com/helena-intel/test-prompt-generator","last_synced_at":"2026-06-20T07:31:08.622Z","repository":{"id":225307040,"uuid":"763457866","full_name":"helena-intel/test-prompt-generator","owner":"helena-intel","description":"Create prompts with a given token length for testing LLMs and other transformers text models.","archived":false,"fork":false,"pushed_at":"2025-08-05T10:20:00.000Z","size":621,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-05T12:15:24.605Z","etag":null,"topics":["benchmarking","llm","llm-inference","nlp","tokenizers","transformers"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helena-intel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-02-26T10:33:18.000Z","updated_at":"2025-07-25T17:50:35.000Z","dependencies_parsed_at":"2024-03-28T22:33:00.224Z","dependency_job_id":"907424d9-356f-4501-8b7c-58ac0d6b49ec","html_url":"https://github.com/helena-intel/test-prompt-generator","commit_stats":null,"previous_names":["helena-intel/prompt_generator","helena-intel/prompt-generator","helena-intel/test-prompt-generator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/helena-intel/test-prompt-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helena-intel%2Ftest-prompt-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helena-intel%2Ftest-prompt-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helena-intel%2Ftest-prompt-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helena-intel%2Ftest-prompt-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helena-intel","download_url":"https://codeload.github.com/helena-intel/test-prompt-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helena-intel%2Ftest-prompt-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34561766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmarking","llm","llm-inference","nlp","tokenizers","transformers"],"created_at":"2025-02-24T14:50:42.179Z","updated_at":"2026-06-20T07:31:08.617Z","avatar_url":"https://github.com/helena-intel.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Test Prompt Generator\n\nCreate prompts with a given token length for testing LLMs and other transformers text models.\n\nPre-created prompts for popular model architectures are provided in .jsonl and .txt files in the [prompts](./prompts) directory.\n\nTo generate one or a few prompts, or to test the functionality, you can use the\n[Test Prompt Generator](https://huggingface.co/spaces/helenai/test-prompt-generator) Space on Hugging Face.\n\n## Install\n\n```shell\npip install git+https://github.com/helena-intel/test-prompt-generator.git transformers\n```\n\nSome tokenizers may require additional dependencies. For example, `sentencepiece` or `protobuf`.\n\n## Usage\n\nSpecify a tokenizer, and the number of tokens the prompt should have. A prompt will be returned that, when tokenized with\nthe given tokenizer, contains the requested number of tokens.\n\nFor tokenizer, use a model_id from the Hugging Face hub, a path to a local directory containing tokenizer.json, or one of the preset tokenizers:\n`['bert', 'blenderbot', 'bloom', 'bloomz', 'chatglm3', 'falcon', 'gemma', 'gpt-neox', 'granite-3', 'llama-3', 'magicoder', 'mistral', 'mpt', 'opt', 'phi-2', 'phi-3.5', 'phi-4', 'pythia', 'qwen1.5', 'qwen3', 'redpajama', 'roberta', 'starcoder', 't5', 'tinyllama', 'vicuna', 'zephyr']`.  The preset tokenizers should work for most models with that architecture,\nbut if you want to be sure, use an exact model_id. [This list](./prompts/README.md) shows the exact tokenizers used for the presets.\n\nPrompts are generated by truncating a given source text at the provided number of tokens. By default\n[Alice in Wonderland](https://archive.org/stream/alicesadventures19033gut/19033.txt) is used; you can also provide your own source.\nA prefix can optionally be prepended to the text, to create prompts like \"Please summarize the following text: [text]\". The\nprompts are returned by the function/command line app, and can also optionally be saved to a .txt or .jsonl file.\n\n\n### Python API\n\n#### Basic usage\n\n```python\nfrom test_prompt_generator import generate_prompt\n\n# use preset value for opt tokenizer\nprompt = generate_prompt(tokenizer_id=\"opt\", num_tokens=32)\n# use model_id\nprompt = generate_prompt(tokenizer_id=\"facebook/opt-2.7b\", num_tokens=32)\n```\n\n#### Slightly less basic usage\n\nAdd a source_text_file and prefix. Instead of source_text_file, you can also pass `source_text` containing a string with the source text.\n\n```python\nfrom test_prompt_generator import generate_prompt\n\nprompt = generate_prompt(\n    tokenizer_id=\"mistral\",\n    num_tokens=32,\n    source_text_file=\"source.txt\",\n    prefix=\"Please translate to Dutch:\",\n    output_file=\"prompt_32.jsonl\",\n)\n```\n\nUse multiple token sizes. When using multiple token sizes, `output_file` is required, should be have .jsonl extension. With multiple token sizes,\n`generate_prompt` does not return anything. The .jsonl `output_file` will contain one line for each token size.\n\n```python\nprompt = generate_prompt(\n    tokenizer_id=\"mistral\",\n    num_tokens=[32,64,128],\n    output_file=\"prompts.jsonl\",\n)\n```\n\n\u003e NOTE: When specifing one token size, the prompt will be returned as string, making it easy to copy and use in a test scenario\nwhere you need one prompt. When specifying multiple token sizes a dictionary with the prompts will be returned. When one prompt is generated, the\noutput file can be saved as .txt or .jsonl. With multiple prompts, save as .jsonl.\n\n### Command Line App\n\n```shell\ntest-prompt-generator -t mistral -n 32\n```\n\nUse `test-prompt-generator --help` to see all options:\n\n```shell\nusage: test-prompt-generator [-h] -t TOKENIZER -n NUM_TOKENS [-p PREFIX] [-o OUTPUT_FILE] [--overwrite] [-v] [-f FILE]\n\noptions:\n  -h, --help            show this help message and exit\n  -t TOKENIZER, --tokenizer TOKENIZER\n                        preset tokenizer id, model_id from Hugging Face hub, or path to local directory with tokenizer files. Options for presets are: ['bert', 'bloom', 'gemma', 'chatglm3', 'falcon', 'gpt-neox',\n                        'llama', 'magicoder', 'mistral', 'opt', 'phi-2', 'pythia', 'roberta', 'qwen', 'starcoder', 't5']\n  -n NUM_TOKENS, --num_tokens NUM_TOKENS\n                        Number of tokens the generated prompt should have. To specify multiple token sizes, use e.g. `-n 16 32`\n  -p PREFIX, --prefix PREFIX\n                        Optional: prefix that the prompt should start with. Example: 'Translate to Dutch:'\n  -o OUTPUT_FILE, --output_file OUTPUT_FILE\n                        Optional: Path to store the prompt as .txt or .jsonl file\n  --overwrite           Overwrite output_file if it already exists.\n  -v, --verbose\n  -f FILE, --file FILE  Optional: path to text file to generate prompts from. Default text_files/alice.txt\n```\n\n## Disclaimer\n\nThis software is provided \"as is\" and for testing purposes only. The author makes no warranties, express or implied, regarding the software's operation, accuracy, or reliability.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelena-intel%2Ftest-prompt-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelena-intel%2Ftest-prompt-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelena-intel%2Ftest-prompt-generator/lists"}