Skip to main content

A simple, high-level Python package for the Lille language model.

Project description

SimpleAI

A simple, high-level API for running the Lille language model.

This package provides an easy-to-use interface for both the Hugging Face Transformers and ONNX Runtime backends, automatically downloading the required model files on first use.

Installation

pip install simpleai-sdk

A Note on ONNX Runtime and GPU Support

The package will automatically try to install the correct version of onnxruntime for your system:

  • If you have a CUDA 12.x+ compatible GPU and torch is installed, it will automatically install onnxruntime-gpu.
  • If you have a CPU-only system, it will install onnxruntime.

Important for CUDA 11.x Users: If you are using CUDA 11.x, pip cannot handle the special installation source automatically. The setup will default to the CPU version and print a warning. To get GPU acceleration, you must run the following command after installing simpleai-sdk:

pip install onnxruntime-gpu --index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-11/pypi/simple/

Quick Start

The lille() function is the main entry point. You can specify either the "huggingface" or "onnx" backend.

Hugging Face Backend (Default)

This is the recommended backend for flexibility and ease of use, especially on GPUs.

from simple_ai import lille

# This will download and cache the model on first run
# You can specify the model version, e.g., "130m-instruct" (default) or "130m-base"
model = lille("huggingface", "130m-instruct") 

# For text completion
prompt = "Artificial Intelligence is"
response = model.generate(prompt, max_new_tokens=50, temperature=0.9)
print(response)

# For chat
print("\n--- Chat Example ---")
response1 = model.chat("What is the capital of France?", max_new_tokens=50, top_k=200)
print(f"Bot: {response1}")

response2 = model.chat("And what is its population?", max_new_tokens=50, top_p=0.90)
print(f"Bot: {response2}")

# Reset the conversation history
model.reset_chat()

ONNX Backend

The ONNX backend is optimized for fast CPU and GPU inference.

from simple_ai import lille

# This will download and cache the model on first run
# You can specify the model version, e.g., "130m-instruct" (default) or "130m-base"
model = lille("onnx", "130m-instruct") 

# For text completion
prompt = "Artificial Intelligence is"
response = model.generate(prompt, max_new_tokens=50, temperature=0.9)
print(response)

# For chat
print("\n--- Chat Example ---")
response1 = model.chat("What is the capital of France?", max_new_tokens=50, top_k=200)
print(f"Bot: {response1}")

response2 = model.chat("And what is its population?", max_new_tokens=50, top_p=0.90)
print(f"Bot: {response2}")

# Reset the conversation history
model.reset_chat()

Advanced Usage (Direct Transformers Access)

If you use the "huggingface" backend, you can still access the underlying transformers model and tokenizer for advanced use cases, just like any standard Hugging Face model.

from simple_ai import lille

# Load the model and tokenizer
lille_hf = lille("huggingface")
model = lille_hf.model
tokenizer = lille_hf.tokenizer

# Example from Hugging Face docs
messages = [{"role": "user", "content": "What is gravity?"}]
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer.encode(input_text, return_tensors="pt").to(model.device)

outputs = model.generate(inputs, max_new_tokens=50)
print(tokenizer.decode(outputs[0]))

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

simpleai_sdk-0.1.1.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simpleai_sdk-0.1.1-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file simpleai_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: simpleai_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for simpleai_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 386baa9b2e6d4a895180d089ff169251a5b84886e5a7ff1df35895b459394814
MD5 89ec66f4b5106a1a4472e4a6f0f80466
BLAKE2b-256 61580d69f24a3cc46bb82b477154b39b5c5dcdb7ea3de347894bf036e1426790

See more details on using hashes here.

File details

Details for the file simpleai_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: simpleai_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for simpleai_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9383d3da30af1d72e5da4d13ac81a9134533e860c28170b3170c938fea221c60
MD5 8a10fb2f4019af1663ac3f4135edb17b
BLAKE2b-256 3a311675315eb368a9dbb5f84043a6530dcb2d93b099d1ff0179f63e1ef7a5bd

See more details on using hashes here.

Supported by

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