How to Use Basaran: Your Open-source Alternative to OpenAI’s API

Aug 12, 2023 | Data Science

If you’ve ever felt boxed in by proprietary APIs like OpenAI’s, you’ll be exhilarated to discover Basaran! Basaran is an open-source alternative that offers a compatible streaming API for text generation models powered by Hugging Face Transformers. This guide walks you through the quick start process, installation methods, basic usage, and troubleshooting tips.

Quick Start with Basaran

In the simplest terms, you can launch Basaran in a matter of commands. Replace the userrepo with your selected model from Hugging Face and X.Y.Z with the latest version available, and run the command below:

docker run -p 80:80 -e MODEL=userrepo hyperonym/basaran:X.Y.Z

Once that’s done, your Playground will be available at http://127.0.0.1 and the API at http://127.0.0.1/v1/completions.

Installation Methods

Basaran can be installed in various ways. Here’s how:

1. Using Docker (Recommended)

Docker images for Basaran are available on both Docker Hub and GitHub Packages.

If you want GPU acceleration, make sure to install the NVIDIA Driver and NVIDIA Container Runtime.

Basaran comes preloaded with essential libraries like CUDA and cuDNN, removing the need for separate installations.

2. Using pip

Follow these steps to install Basaran with pip:

  1. Create and activate a virtual environment.
  2. Use pip to install Basaran:
  3. pip install basaran
  4. Install additional dependencies for GPU acceleration (optional):
  5. pip install accelerate bitsandbytes
  6. Run Basaran by replacing userrepo:
  7. MODEL=userrepo PORT=80 python -m basaran

3. Running From Source

If you prefer to run from the source, here is how:

  1. Clone the repository:
  2. git clone https://github.com/hyperonym/basaran.git  
    cd basaran
    
  3. Install dependencies:
  4. pip install -r requirements.txt
  5. Run Basaran by replacing userrepo:
  6. MODEL=userrepo PORT=80 python -m basaran

Basic Usage of Basaran

Basaran supports consistent HTTP request and response formats similar to those of OpenAI’s API. Here’s how you can make a text completion request using cURL:

curl http://127.0.0.1/v1/completions \
-H "Content-Type: application/json" \
-d '{"prompt": "once upon a time", "echo": true}'

Your response will display the generated text, completion tokens, and other metadata.

Troubleshooting

If you run into issues such as connectivity problems or errors while interacting with Basaran, here are some tips:

  • Ensure that your Docker container is running correctly and is binding to the intended port.
  • Check your model name and ensure it is correctly referenced in both the Docker command and in other model-loading calls.
  • For any compatibility issues with requests, consider inspecting your API call format against Basaran’s documentation.
  • Revisit the dependencies you’ve installed especially if you’re running GPU checked models.

If difficulties persist, seek support and share your experiences: For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

Basaran is a powerful open-source alternative that opens new avenues for developers seeking robust language model capabilities without the constraints of proprietary systems.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox