Skip to main content

smoltex

Convert natural language descriptions to LaTeX equations within your terminal in under one second!

features

You can use smoltex for either a single instruction or to directly edit a given markdown file.

For the equations that can be rendered in a single line, it will open a new window where the rendered equation will be shown.

Example for a single instruction.

  • Negative Log Likelihood loss in ML NLL

To edit a markdown file directly using smoltex, you can specify the start and end delimiters (identifiers) between which your instructions should be.

Consider your markdown file has some content like:

Einstein said that:
<start> an equation for einstein's field equations </start>

In quantum mechanics, there is something called the wave function:

<start> notation of the wave function </start>

And you want to replace your instructions between <start> and </start> with the actual latex equations, you can use smoltex to help you out. In the command, specify the input file to edit along with the start and end delimiters using the -sd and -ed options respectively:

smoltex -f ./example.md -sd "<start>" -ed "</start>"

smoltex will directly edit the markdown file and replace your instructions with the latex equations.

An example:

  • Edit markdown file markdown

how to use?

smoltex can be used in two ways:

  1. External API generation
  2. Local generation

Using External API generation

For the API, this project uses Groq platform for very fast response generation, so you will need to setup an API key for it. Groq provides a free tier API for personal usage.

To use external API generation, follow the steps below.

Step 1: setup

  • Visit the Groq console to create your API key for free.

  • Then in the terminal of your choice, paste the below line:

    export GROQ_API_KEY=<your-api-key-here>
    

or add this line to your .bashrc or .zshrc file for persistent usage.

Step 2: use

In the current terminal session, the command for using smoltex is smoltex followed by the natural language description of the latex equation you want:

smoltex "equation for cross entropy"

Local generation

We use llama_cpp_python, pytorch, and transformers if you want to have local generations.

Follow the steps below.

  1. Install llama-cpp-python with your device's accelerator.

    • For CUDA-enabled devices:
    CMAKE_ARGS="-DGGML_CUDA=on" pip install llama-cpp-python
    
    • For MacOS M-chips:
    CMAKE_ARGS="-DGGML_METAL=on" pip install llama-cpp-python
    
    • Otherwise:
    pip install llama-cpp-python
    
  2. Install smoltex:

pip install "smoltex[local]"
  1. Use
smoltex "equation for cross entropy"

The output will be the latex string of the requested description. You can paste the equation in any latex renderer to see the result.

While using smoltex you can specify something called "servers" using the -s or --server argument. Basically, you can either use groq or llama-cpp as a server for your generations. As of now, groq is the default server.

available models

Using the -m or --model_name option, you can choose to generate the latex string with different models as well. Available models (as of now) are:

Llama 3 variants:
- llama3-8b
- llama3-70b

Gemma variants:
- gemma-7b
- gemma2

Mistral variants:
- mixtral-8x7b

Phi3 (available locally only)
- phi-3-mini

Example command for different models:

smoltex "equation for cross entropy" -m "mixtral-8x7b-32768"

Release files for smoltex 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smoltex 0.2.1
File Size Uploaded
smoltex-0.2.1.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for smoltex 0.2.1
File Interpreter ABI Platform
smoltex-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.8 kB

Release files / smoltex-0.2.1.tar.gz

Download URL smoltex-0.2.1.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
18e3339f39353274aae7a91a0ca40c02826403b2c3e29b4073d0d9c0570c6118
BLAKE2b-256 checksum
How to use checksums
b804077f5c4d04de3cb0290c4d59da3efb6e59f7c04fd560878d35e75c4db857
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.18

Release files / smoltex-0.2.1-py3-none-any.whl

Download URL smoltex-0.2.1-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5603363b0b2016e258743b7d7a6341df783d7947f09b99e5176a9e8738f95d1e
BLAKE2b-256 checksum
How to use checksums
16aac69a5c1c9f6838f0794280c3dd9ba8b9b209cc571a8699b4b91db5703457
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page