Generate Targets

Generate Targets

Once pyrmap is installed, you can orchestrate target-generation workflows directly from Python.

Discover available algorithms

>>> import pyrmap
>>> pyrmap.get_available_tgas()
['entropy', 'random', 'sixgen', 'sixforest', 'sixgraph', 'sixtree', 'det', 'sixprobe', 'sixgan', 'sixgcvae', 'sixveclm']

Use these identifiers with both training and generation helpers.

Train a model from seed data

import json
import pyrmap

config = json.dumps({
    "budget": 1_000_000,
    "clusters": 24,
})

model_bytes, summary = pyrmap.train_model(
    algorithm="sixgen",
    seeds_path="data/seeds.txt",
    output_path="models/sixgen.bin",
    config_json=config,
)

print(summary)
print(f"Wrote {len(model_bytes)} bytes to models/sixgen.bin")
  • seeds_path points to a newline-delimited IPv6 seed file.
  • output_path is optional; omit it to receive the bytes without touching disk.
  • Pass config_json=None to keep algorithm defaults.

Async training

Run the training helper inside an event loop with asyncio.to_thread:

import asyncio
import pyrmap

async def train_async():
    return await asyncio.to_thread(
        pyrmap.train_model,
        algorithm="sixforest",
        seeds_path="data/seeds.txt",
        output_path="models/sixforest.bin",
        config_json=None,
    )

asyncio.run(train_async())

Generate addresses from a trained model

import pyrmap

targets = pyrmap.generate_targets(
    model_path="models/sixgen.bin",
    count=10_000,
    unique=True,
    max_attempts=1_000_000,
    exclude_path=None,
    seed=None,
)

with open("targets.txt", "w", encoding="utf-8") as fh:
    fh.write("\n".join(targets))
  • Set unique=False when you only need a quick sample.
  • max_attempts caps how many duplicates the generator tolerates when uniqueness is required.
  • Provide exclude_path to filter out known-bad addresses during generation.
  • Seed the generator for reproducible runs.

Work in batches

When you need millions of addresses, loop over smaller batches:

import pyrmap

with open("targets-large.txt", "w", encoding="utf-8") as fh:
    for _ in range(50):
        for addr in pyrmap.generate_targets(
            model_path="models/sixforest.bin",
            count=100_000,
            unique=True,
        ):
            fh.write(addr + "\n")

Batching keeps memory usage predictable while still producing multi-million-line target files.

Mix CLI and Python generators

  • Train in Python and share the resulting .bin file with teammates who prefer the CLI.
  • Already have a CLI recipe? Call it with subprocess.run(["rmap", "generate", ...]) and pipe the output back into your script.
  • Need the raw bytes? Read them with Path("models/sixgen.bin").read_bytes() and push them into downstream services.