Skip to main content

Convert natural language descriptions to LaTeX equations

Project description

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"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smoltex-0.2.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

smoltex-0.2.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file smoltex-0.2.0.tar.gz.

File metadata

  • Download URL: smoltex-0.2.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.18

File hashes

Hashes for smoltex-0.2.0.tar.gz
Algorithm Hash digest
SHA256 510101d886230e4f69ae2adaa5597c5dd2763d5770813dd7800b200808ccdebb
MD5 a859a085b3f65a1401f22f585e9b9d00
BLAKE2b-256 eee009abac6f2d8b45dcc7bd8507168f6a92e2246e1d276123bc2481bf34891b

See more details on using hashes here.

File details

Details for the file smoltex-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: smoltex-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.18

File hashes

Hashes for smoltex-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 727c20fe99ed0526b0b07f6cad5f203de7b2f75e1ca2e7f6fd0eb528316424f1
MD5 b86ae01e4dff2b6664f2fb7ca37a44f1
BLAKE2b-256 a72a18d9606cd66b86982fa33987ceeb574857f292f28197660707c006f69e54

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page