Have you ever ever thought-about having a dialog with an clever laptop? Or maybe you’re occupied with creating progressive tasks base on Magento with AI LLM LLama2 ? Properly, check out LLama2 ! It’s the most recent very smart laptop program developed by Meta AI, a division of Meta (previously often called Fb).
What’s LLama2?
Llama 2 is a part of a gaggle of sensible AI referred to as massive language fashions (LLMs). These machines can create and perceive human language. They get actually sensible with enormous quantities of textual content from all kinds of locations like books, web sites, and social media. This helps them learn the way phrases and sentences work in several conditions and matters.
How can we use it and its set up course of?
There are a number of methods to make use of LLama2, we’re discussing it to apply it to the native system or on a cloud hosted server for that we will use the ollama.
About ollama
Ollama is a helpful device that permits you to use open-source massive language fashions (LLMs) proper by yourself laptop. It really works with completely different fashions like Llama 2, Code Llama, and extra. It gathers the whole lot these fashions want – like their settings, knowledge, and code – into one neat bundle referred to as a Modelfile. Ollama simplifies autonomous studying and adjustment, minimising the requirement for in depth handbook reprogramming and fine-tuning of AI methods. We are able to use this to make varied functions like pure language processing and picture recognition.
Ollama Set up:
For Home windows:
https://ollama.com/obtain/home windows
For Mac:
For Linux:
Set up it utilizing a single command:
curl -fsSL https://ollama.com/set up.sh | sh
Ollama Helps checklist of fashions obtainable on https://ollama.com/library
Beneath are listed just a few fashions.
Please remember the fact that working the 7B fashions requires a minimal of 8 GB of RAM, whereas the 13B fashions want 16 GB, and the 33B fashions want 32 GB.
After ollama set up, you’ll be able to simply fetch any of the fashions utilizing a easy pull command.
ollama pull llama2
After finishing the pull command, you’ll be able to run it immediately within the terminal for textual content era.
For Instance.
ollama run llama2
![Llama2 run on terminal.](https://cdnblog.webkul.com/blog/wp-content/uploads/2024/02/screenshot_from_2024_02_21_11_56_06-1200x403.png)
Ollama additionally provides a REST API for working and managing fashions.
See the API Documentation for the endpoints.
How can we use it in Magento?
As A Buying Assistant:
With Llama-2, you’ll be able to develop chat bots able to conversing naturally with folks. You could have the flexibleness to tailor these chat bots to suit your particular area, persona, and tone.
For auto generate content material of merchandise :
Utilizing Llama-2, you’ll be able to generate content material of merchandise base on merchandise Title , SKU or different attributes as your want.
Ex. utilizing following methodology you’ll be able to generate content material of merchandise base on product identify and set in product description as your want.
<?php namespace WebkulOllamaModel; class AIContent { /** * @var MagentoFrameworkHTTPClientCurl */ protected $curl; /** * @param MagentoFrameworkHTTPClientCurl $curl */ public operate __construct( MagentoFrameworkHTTPClientCurl $curl ) { $this->curl = $curl; } /** * Get AI content material * * @param string $productName * @return string */ public operate getAIContent($productName) { $this->curl->addHeader('content-type', 'utility/json'); $arr = [ CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_POSTFIELDS =>'{"model":"llama2","prompt":"Product Specification and description for "'.$productName.',"stream": false}' ]; $this->curl->setOptions($arr); //Right here we go Ollama server finish level. $this->curl->put up('http://XXX.XXX.XX.XXX:11434/api/generate', []); $productContent = json_decode($this->curl->getBody(), true); return $productContent['response']; } } Thanks !!
Have you ever ever thought-about having a dialog with an clever laptop? Or maybe you’re occupied with creating progressive tasks base on Magento with AI LLM LLama2 ? Properly, check out LLama2 ! It’s the most recent very smart laptop program developed by Meta AI, a division of Meta (previously often called Fb).
What’s LLama2?
Llama 2 is a part of a gaggle of sensible AI referred to as massive language fashions (LLMs). These machines can create and perceive human language. They get actually sensible with enormous quantities of textual content from all kinds of locations like books, web sites, and social media. This helps them learn the way phrases and sentences work in several conditions and matters.
How can we use it and its set up course of?
There are a number of methods to make use of LLama2, we’re discussing it to apply it to the native system or on a cloud hosted server for that we will use the ollama.
About ollama
Ollama is a helpful device that permits you to use open-source massive language fashions (LLMs) proper by yourself laptop. It really works with completely different fashions like Llama 2, Code Llama, and extra. It gathers the whole lot these fashions want – like their settings, knowledge, and code – into one neat bundle referred to as a Modelfile. Ollama simplifies autonomous studying and adjustment, minimising the requirement for in depth handbook reprogramming and fine-tuning of AI methods. We are able to use this to make varied functions like pure language processing and picture recognition.
Ollama Set up:
For Home windows:
https://ollama.com/obtain/home windows
For Mac:
For Linux:
Set up it utilizing a single command:
curl -fsSL https://ollama.com/set up.sh | sh
Ollama Helps checklist of fashions obtainable on https://ollama.com/library
Beneath are listed just a few fashions.
Please remember the fact that working the 7B fashions requires a minimal of 8 GB of RAM, whereas the 13B fashions want 16 GB, and the 33B fashions want 32 GB.
After ollama set up, you’ll be able to simply fetch any of the fashions utilizing a easy pull command.
ollama pull llama2
After finishing the pull command, you’ll be able to run it immediately within the terminal for textual content era.
For Instance.
ollama run llama2
![Llama2 run on terminal.](https://cdnblog.webkul.com/blog/wp-content/uploads/2024/02/screenshot_from_2024_02_21_11_56_06-1200x403.png)
Ollama additionally provides a REST API for working and managing fashions.
See the API Documentation for the endpoints.
How can we use it in Magento?
As A Buying Assistant:
With Llama-2, you’ll be able to develop chat bots able to conversing naturally with folks. You could have the flexibleness to tailor these chat bots to suit your particular area, persona, and tone.
For auto generate content material of merchandise :
Utilizing Llama-2, you’ll be able to generate content material of merchandise base on merchandise Title , SKU or different attributes as your want.
Ex. utilizing following methodology you’ll be able to generate content material of merchandise base on product identify and set in product description as your want.
<?php namespace WebkulOllamaModel; class AIContent { /** * @var MagentoFrameworkHTTPClientCurl */ protected $curl; /** * @param MagentoFrameworkHTTPClientCurl $curl */ public operate __construct( MagentoFrameworkHTTPClientCurl $curl ) { $this->curl = $curl; } /** * Get AI content material * * @param string $productName * @return string */ public operate getAIContent($productName) { $this->curl->addHeader('content-type', 'utility/json'); $arr = [ CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_POSTFIELDS =>'{"model":"llama2","prompt":"Product Specification and description for "'.$productName.',"stream": false}' ]; $this->curl->setOptions($arr); //Right here we go Ollama server finish level. $this->curl->put up('http://XXX.XXX.XX.XXX:11434/api/generate', []); $productContent = json_decode($this->curl->getBody(), true); return $productContent['response']; } } Thanks !!