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.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: smoltex-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 18e3339f39353274aae7a91a0ca40c02826403b2c3e29b4073d0d9c0570c6118
MD5 b126ab6b2a01b0dd1b131cfcf6315e1d
BLAKE2b-256 b804077f5c4d04de3cb0290c4d59da3efb6e59f7c04fd560878d35e75c4db857

See more details on using hashes here.

File details

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

File metadata

  • Download URL: smoltex-0.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5603363b0b2016e258743b7d7a6341df783d7947f09b99e5176a9e8738f95d1e
MD5 99e58505c6c7938f753509bad0095f26
BLAKE2b-256 16aac69a5c1c9f6838f0794280c3dd9ba8b9b209cc571a8699b4b91db5703457

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