The choice between open-source and Proprietary Language models depends on various factors, which include your specific need, budget, and availability of resources like a tech team, required data, etc.
Open Source LM:
- Free to Use: Open source models are free to use which can be of significant advantage for businesses with budget constraints, especially smaller e-commerce startups.
1234567891011import { pipeline } from '@xenova/transformers';let question = 'Who was Jim Henson?';let context = 'Jim Henson was a nice puppet.';let answerer = await pipeline('question-answering', 'Xenova/distilbert-base-uncased-distilled-squad');let output = await answerer(question, context);// {// "answer": "a nice puppet",// "score": 0.5768911502526741// }
Here, we are using a pre-trained “Xenova/distilbert-base-uncased-distilled-squad” Language Model for ‘question-answering’. To use this you just need to install transformers by running ‘npm install transformers’. - Customization: You have more control over open-source models and they can be customized as per the requirements. You can also fine-tune open-source models over your data and adapt it to your use case.
- Transparency: Open source models are more transparent in terms of how they work and what data they are trained on, which can be important for compliance and preparing the data for finetuning.
- Community and Flexibility: Open-source models often have an active community of developers and researchers. This means you can benefit from continuous improvements, updates, and a wide range of available resources and extensions.
Considering Open Source LM for E-commerce:
- Expertise required: To effectively use and customize open-source LLMs, you may need a team with expertise in Natural Language Processing and Machine Learning.
- Resource Intensive: Training and fine-tuning open-source models will require proper data and computational power.
- Training Required: The above model is trained to answer the question from a given set of documents, but it will just provide the raw answer rather than presenting it in a nice manner as it should be for e-commerce use. So, you need to fine-tune this to answer in a specific manner. To use it in our Chatbot Module, you need to train it for conversations.
Proprietary LLM:
- Easy to use: Proprietary LLMs are often designed to be user-friendly and come with a dedicated support team, making them easier to use.
1234567891011121314151617181920212223242526272829303132333435363738import { ChatOpenAI } from "langchain/chat_models/openai";import { ConversationalRetrievalQAChain } from "langchain/chains";import { HNSWLib } from "langchain/vectorstores/hnswlib";import { OpenAIEmbeddings } from "langchain/embeddings/openai";import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";import { BufferMemory } from "langchain/memory";import * as fs from "fs";export const run = async () => {/* Initialize the LLM to use to answer the question */const model = new ChatOpenAI({});/* Load in the file we want to do question answering over */const text = fs.readFileSync("state_of_the_union.txt", "utf8");/* Split the text into chunks */const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });const docs = await textSplitter.createDocuments([text]);/* Create the vectorstore */const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());/* Create the chain */const chain = ConversationalRetrievalQAChain.fromLLM(model,vectorStore.asRetriever(),{memory: new BufferMemory({memoryKey: "chat_history", // Must be set to "chat_history"}),});/* Ask it a question */const question = "What did the president say about Justice Breyer?";const res = await chain.call({ question });console.log(res);/* Ask it a follow up question */const followUpRes = await chain.call({question: "Was that nice?",});console.log(followUpRes);};
This is using OpenAI API to answer the user’s query from the given set of documents. This can be used in e-commerce as a chatbot for answering the user’s query regarding products, return policy, shipment policy, etc. - Performance: Some Proprietary LLMs are fine-tuned for specific tasks like user-friendly conversation, which proves to be very useful for e-commerce applications.
- Giving Conversational Answers without any specific training: You are not required to separately train this model to answer the user’s query in a professional manner. Because of its impressive responses and ease of use, we at Bagisto have used the OpenAI LLM in our Chatbot Module.
Considerations for Proprietary LLMs:
- Cost: Proprietary LLMs typically come with subscription/licensing fees, which can be a significant ongoing cost.
- Customization Limitations: Proprietary LLMs may offer less flexibility for customization compared to open-source models.
In summary, the choice between open-source and proprietary LLMs depends on your specific circumstances:
- If you have the technical expertise, data, and computational power, open-source LLM can be a great solution without any subscription or licensing fees.
- If you prioritize ease of use and better responses without getting into the depth of the model and other complications. Then proprietary LLMs would be best for you.