A new package designed to extract and structure key technical specifications from quantum computing research and development texts. The package takes unstructured text input describing quantum process
Project description
quantum-spec-parser
quantum-spec-parser is a lightweight Python package that extracts and structures key technical specifications from unstructured quantum computing texts. It parses descriptions of quantum processors and returns a standardized list containing essential details such as qubit count, material composition, and fidelity ranges.
The package relies on the llmatch‑messages library for robust pattern matching and uses ChatLLM7 (from langchain_llm7) as the default language model. You can also supply any LangChain‑compatible LLM of your choice.
📦 Installation
pip install quantum_spec_parser
🚀 Quick Start
from quantum_spec_parser import quantum_spec_parser
# Example unstructured description of a quantum processor
user_input = """
The new Q-42 chip features 56 superconducting transmon qubits fabricated on a silicon substrate.
Gate fidelity lies between 99.2% and 99.7%, and the coherence time averages 120 µs.
"""
# Simple call – uses the default ChatLLM7 internally
specs = quantum_spec_parser(user_input)
print(specs)
# → ['56 qubits', 'silicon substrate', 'fidelity 99.2%‑99.7%', 'coherence time 120 µs']
📚 Detailed Usage
Function Signature
def quantum_spec_parser(
user_input: str,
api_key: Optional[str] = None,
llm: Optional[BaseChatModel] = None,
) -> List[str]:
| Parameter | Type | Description |
|---|---|---|
user_input |
str |
The raw text containing quantum processor specifications. |
api_key |
Optional[str] |
Your LLM7 API key. If omitted, the function reads LLM7_API_KEY from the environment or falls back to a placeholder. |
llm |
Optional[BaseChatModel] |
A LangChain LLM instance to use instead of the default ChatLLM7. Any model that implements BaseChatModel works. |
If llm is not provided, the function automatically creates a ChatLLM7 instance using the supplied (or env‑provided) API key.
Using a Custom LLM
You can replace the default ChatLLM7 with any LangChain‑compatible model, such as OpenAI, Anthropic, or Google Generative AI.
OpenAI
from langchain_openai import ChatOpenAI
from quantum_spec_parser import quantum_spec_parser
llm = ChatOpenAI(model="gpt-4o-mini")
response = quantum_spec_parser(user_input, llm=llm)
Anthropic
from langchain_anthropic import ChatAnthropic
from quantum_spec_parser import quantum_spec_parser
llm = ChatAnthropic(model="claude-3-haiku-20240307")
response = quantum_spec_parser(user_input, llm=llm)
Google Generative AI
from langchain_google_genai import ChatGoogleGenerativeAI
from quantum_spec_parser import quantum_spec_parser
llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
response = quantum_spec_parser(user_input, llm=llm)
Supplying Your Own LLM7 API Key
The free tier of LLM7 usually suffices, but for higher rate limits you can provide a personal key:
response = quantum_spec_parser(user_input, api_key="your-llm7-api-key")
Or set it globally via the environment:
export LLM7_API_KEY="your-llm7-api-key"
You can obtain a free key by registering at https://token.llm7.io/.
🛠️ Under the Hood
- Prompt construction – The package builds system and human prompts defined in
prompts.py. - Pattern matching – A regular expression (
pattern) is compiled and passed tollmatchfromllmatch_messages. - LLM call – The selected LLM generates a response.
- Extraction –
llmatchvalidates the response against the regex and returns the extracted data as a list of strings.
If the LLM call fails or the response does not match the pattern, a RuntimeError is raised with the underlying error message.
🐞 Issues & Contributions
If you encounter bugs or have feature requests, please open an issue:
Pull requests are welcome! Feel free to fork the repository and submit your improvements.
✍️ Author
Eugene Evstafev – hi@euegne.plus
GitHub: chigwell
📜 License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quantum_spec_parser-2025.12.21131621.tar.gz.
File metadata
- Download URL: quantum_spec_parser-2025.12.21131621.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9d424b33ba39d7d56dead8bfc3c720d2abbfd22f268def80bcfab10b4b6db66
|
|
| MD5 |
fa084cb6c1258dde1260048b019d653e
|
|
| BLAKE2b-256 |
5fab79c793d741b4d7c260e59271ece26dfed18df34acfe7dc090cf71456ff3f
|
File details
Details for the file quantum_spec_parser-2025.12.21131621-py3-none-any.whl.
File metadata
- Download URL: quantum_spec_parser-2025.12.21131621-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1819d892e04edb6c2422c48002669780a241eb9ee901e3a3ffdd7b5d3c5a1535
|
|
| MD5 |
5c76004b3dd55f61e99d258bfa0a49a2
|
|
| BLAKE2b-256 |
d335efaccab39853e034a6e35c527ad10aec86098c7a795b462812dcc73f4057
|