Closed VeriHeppi closed 1 month ago
Asking ChatGPT with the following prompt:
"I am creating an LLM-based text classifier. The purpose of this project is to input text-based data and have the program analyse and classify themes and other things from the data. The program will run locally and will likely be created using Python, and will also use Docker or Podman. What LLM should I use for this task? My choices are Mistral, Llama, GPT@Azure, Gemini and CSC Lumi. Consider the upsides and downsides of each LLM and suggest one or more for my use case."
The answer:
For your LLM-based text classifier project, here’s a breakdown of the five LLMs you’re considering, focusing on their key strengths and weaknesses to help guide your decision. Your goal is to classify themes and analyze text data locally, likely using Python with Docker/Podman, so compatibility, ease of integration, performance, and licensing are essential considerations.
Downsides:
Best for: If you want an open-source model that is efficient and can be run with fewer resources locally.
Downsides:
Best for: If you need a widely-used, open-source, and well-documented model with strong NLP capabilities and flexibility for local deployment.
Downsides:
Best for: If you need cutting-edge performance and are okay with using Azure’s cloud infrastructure (but this doesn’t align with your local-first approach).
Downsides:
Best for: If you need multilingual support and are open to using Google Cloud (but again, this doesn’t align with your local deployment needs).
Downsides:
Best for: Large-scale projects needing HPC resources, but may not be a great fit for your local-first and Docker-based setup.
For your use case of a locally-deployed text classifier, focusing on ease of integration with Python, Docker/Podman, and a preference for local execution, LLaMA 2 and Mistral are the top choices:
LLaMA 2: Offers the best balance between performance, community support, and local deployment. It has strong text classification capabilities, with a wide range of tools and libraries that will make integration easier. LLaMA 2 is open-source but may have some licensing restrictions on commercial use.
Mistral: A great lightweight, open-source option that could be more resource-efficient if your hardware is limited. Mistral is highly suitable if you want a more agile model that can still perform well for NLP tasks like classification, while running locally with minimal overhead.
Between LLaMA 2 and Mistral, LLaMA 2 is likely to give you stronger results for text classification if you have the hardware to support it, while Mistral is better for a resource-efficient, open-source, local solution.
Asking Gemini with the same prompt:
Understanding your requirements:
Comparing LLMs:
Mistral:
Llama:
GPT@Azure:
Gemini:
CSC Lumi:
Recommendations:
Given your requirements for local deployment, Python integration, and containerization, Mistral or Llama would be excellent choices. Both are open-source, well-supported, and can be fine-tuned for your specific text classification task.
Additional considerations:
By carefully considering these factors, you can select the LLM that best suits your text classification project and provides the desired performance and flexibility.
When asking Mistral:
Choosing the right Large Language Model (LLM) for your text classifier project depends on several factors, including performance, ease of use, cost, and specific requirements. Let's evaluate the options you've mentioned:
Upsides:
Downsides:
Upsides:
Downsides:
Upsides:
Downsides:
Upsides:
Downsides:
Upsides:
Downsides:
For Open Source and Customization:
For Ease of Use and Performance:
For Specialized Needs:
Given your use case of running the program locally (with cloud solutions possible) and using Python along with Docker or Podman, Mistral or Llama would be excellent choices if you have the technical expertise to set them up and fine-tune them. They offer the flexibility and customization you need without direct costs.
If you prefer a more managed solution with high performance and are willing to pay for it, GPT@Azure is a strong option. It simplifies deployment and scaling, and you can leverage Microsoft's infrastructure and support.
Ultimately, the choice depends on your specific requirements, budget, and technical capabilities.
Preliminary research seems to point to Mistral, next up is more research on how to use it.
ChatGPT on how to set up Mistral using Python & Podman:
To create an LLM (Large Language Model) program using Python, Podman, and the Mistral LLM on Windows, you'll need to follow a series of steps to set up the environment. Here's a detailed guide on what you need and how to set it up:
Ensure that Python is installed on your Windows machine. You can download the latest version of Python from the official website: Python.org. During installation, make sure to select the option to Add Python to PATH.
Podman is a containerization platform similar to Docker but designed to be daemonless. Here's how to install Podman on Windows:
Download Podman: Visit the official Podman Windows installation page and follow the steps to install Podman for Windows.
WSL2 Installation: Podman on Windows requires Windows Subsystem for Linux 2 (WSL2). If you don’t have WSL2 installed, follow these steps:
wsl --install
Set Up WSL2 for Podman:
wsl --set-version <your-distro> 2
Replace <your-distro>
with the name of your installed WSL Linux distribution.
Install Podman Desktop: Download and install Podman Desktop from Podman Desktop releases to manage containers graphically and use Podman more effectively.
Run Podman: Open Podman Desktop or use the command line inside the WSL terminal to run Podman commands.
Once Podman is set up, you can create and run a container with the Mistral LLM model inside it.
Search for Mistral LLM Image: First, search for the Mistral LLM container image, or create your own Dockerfile if no prebuilt image is available.
podman search mistral
Pull the Mistral Image or Build from Dockerfile:
podman pull mistral/mistral-llm:latest
podman build -t mistral-llm .
Run the Container:
podman run -it --rm mistral/mistral-llm:latest
Now that Mistral LLM is running inside a Podman container, you'll need to set up Python on Windows to interact with the model.
Install requests
or another HTTP library (if you will interact with the LLM via an API):
pip install requests
Set Up a Python Script to Connect with Mistral:
If Mistral LLM exposes an API, you can write a Python script to send requests to the Mistral instance running inside the Podman container. Here's an example:
import requests
# Replace with the correct URL for the running Mistral LLM API
url = "http://localhost:8000/api/v1/generate"
headers = {"Content-Type": "application/json"}
data = {
"prompt": "What is the capital of France?",
"max_tokens": 50
}
response = requests.post(url, json=data, headers=headers)
if response.status_code == 200:
print(response.json())
else:
print(f"Error: {response.status_code}")
Exposing Ports from the Podman Container: Ensure that the Mistral LLM container exposes the necessary ports so that Python on Windows can communicate with it. For example:
podman run -it -p 8000:8000 mistral/mistral-llm:latest
Once everything is set up:
To automate your setup, you can write a batch or PowerShell script to launch the container and your Python script in sequence.
requests
)With this setup, you'll have a containerized LLM (Mistral) running in Podman on your Windows machine, and you'll use Python to interact with it via an API or other interface.
I also had the same kind of discussion with ChatGPT as Vertti and came to the same conclusion that Mistral & LLAMA are the best options.
Since LLAMA and Gemini are developed by Meta's and Google's it is known how these companies make money. So I leaned towards Mistral on this one myself. Here is some conversation with ChatGPT about the subject.
"Mistral AI models, being open-weight and designed for use in local or private settings, do not collect user data by default. The responsibility for data privacy lies with the developer or organization using the model. Unlike larger companies like Meta or Google, Mistral AI does not operate a centralized advertising or data-sharing ecosystem, and there’s no indication that it collects or sells user data for marketing purposes."
My only question is: is mistral free to use? While researching the topic, I came across information that it would no longer be free after August 2024.
While researching LLM integration I came across several ways and wondered if, for example, a modular approach or ensemble learning techinique would be good for this project?
Mistral is not free. The price is $2 per 1 million tokens for input and $6 per 1 million for output for the best model and $0,15 per 1 million tokens for the new Pixtral 12B version.
Llama 3.1 price varies (https://www.llama.com/)
Running some models locally is possible but takes heavy amounts of GPU VRAM (https://ollama.com/library)
Results:
Client opinion:
Research into possible LLM models: Mistral, Llama (Meta), GPT@Azure, Gemini, CSC LUMI, etc.
Possible to combine multiple LLM models?