Sunday, September 15, 2024

Run Llama 3 on your laptop

Ollama is a convenient platform for the local development of open-source AI models. 

Why should you use open-source AI? \


Today, we have access to powerful Large Language Models, such as GPT-4o or Clause 3.5 Sonnet. 

But they come with 4 major problems: 



Data Privacy. When “talking” to GPT-4 you always send your data to the OpenAI server. For most companies, this is the #1 reason NOT to use AI. 


Cost. The best-performing LLMs are expensive, especially for high-volume applications. 


Dependency. Using GPT-4 or Claude means you rely on OpenAI or Anthropic. Most businesses prefer independence. 


Limited Customization. Every business has unique needs and problems. Custom solutions are crucial for many. But customizing the biggest models is possible only through Prompt Engineering. 


Let’s compare it to the open-source models: 

Full Privacy
We run open-source models locally. Which means, we don’t send the data anywhere. They can work offline! 

Lower Cost. You can use many “local” models for free. You pay for more powerful ones, but they’re much cheaper than GPT-4. 
Independence & Control. You’ve got full control over the model. Once you download it to your computer, you “own” it. 
Customization. You can fine-tune, re-train, and modify open-source LLMs to fit your specific needs.

But of course, open-source LLMs have their own limitations: 

Worse Performance. Reasoning and general performance of open-source LLMs always lag behind GPT-4. 
Integration Challenges. Integrating them requires more expertise and effort. 
Hardware costs. LLMs require high computational power. To run them for high-volume applications, you need your own GPUs. 

Running local Llama 3 with Ollama. 
All you need: Download Ollama on your local system. 
Download one of the local models on your computer using Ollama. For example, if I want to use Llama3, I need to open the terminal and run: 

$ ollama run llama3 

If it’s the first time you use the model, Ollama will first download it. 
Because it has 8B parameters, it’ll take a while. 
 Once you download the model, you can use it through Ollama API. 
To install Ollama API, run the following command: 
 $ pip install ollama 

And with these steps, you’re ready to run the code from this article. 

 In this article, we’ll explore how to use open-source Large Language Models (LLMs) with Ollama. We’ll go through the following topics: Using open-source models with Ollama. 

The importance of the system prompt. Streaming responses with Ollama. The practical applications of the LLM temperature. 

The usage and limitations of the max tokens parameter. Replicating “creative” responses with the seed parameter

Getting the Simple Response

import ollama

model = "llama3"
response = ollama.chat(
model=model,
messages=[
{"role": "user", "content": "What's the capital of Poland?"}
]
)
print(response["message"]["content"])

## Prints: The capital of Poland is Warsaw (Polish: Warszawa).
  1. import ollama to use Ollama API
  2. model = "llama3 to define the model we want to use
  3. ollama.chat() to get the response. We used 2 parameters:
    model that we defined before
    messages where we keep the list of messages

Sunday, February 18, 2024

OLTP and OLAP

When to use OLAP vs. OLTP Online analytical processing (OLAP) and online transaction processing (OLTP) are two different data processing systems designed for different purposes. OLAP is optimized for complex data analysis and reporting OLTP is optimized for transactional processing and real-time updates.

Tuesday, February 13, 2024

test

1. snowflake pvt link 1) Gary and Justin to followup with GIS team 2) Swamy to document the 3 options with Pros and Cons diucssed 3) What is the data classification and volume? What is the data stored in snowflake next week - setting up followup meeting 2. monday.con network integration Dev team want the bi-directional api communication wher lambda /EKS to call monday.com API and also monday.com to call Lamba/EKS

Monday, January 29, 2024

Cyber Security Standards - Risk Based Framework

Purpose

  • The Risk Based Framework (RBF) is a risk classification system developed by the Enterprise Cyber Security (ECS) department of the Cyber Risk Management team. 
  • ECS policy is intended to protect the firm in an evolving threat landscape, regardless of changes in technology or business practices. 
  • Even if specific terminology or scenarios are not part of the text, it is expected that you will exercise sound reasoning and judgment to adhere to the intent of stated requirements, practices, and implementations in both letter and spirit.


Scope

  • All systems that are listed in the IT Service Manager (ITSM) application (e.g., ServiceNow), are required to have an RBF classification. 
  • All systems where the lifecycle stage is ‘Concept’, ‘Acquisition/Development’, or ‘Retired’ are not in scope.

Thursday, January 18, 2024

Conversational AI

 

Conversational AI Applications 


Design 

Developing a bot, like developing websites and applications, should start with a design for a great experience. When humans interact with bots, we expect that what we say is understood, what we receive as a response is appropriate, and what we get as a service is delight‐ ful. We expect that, if we leave mid-conversation, the bot will remember where we left off.

Build

 A bot is a representational state transfer (REST) web service that communicates with the user by sending and receiving messages and events from conversational interfaces like chat rooms or Web Chat widgets. With Microsoft’s Azure Bot Service and Bot Framework, you can create bots in a variety of development environments and languages. You can start your bot development in the Azure portal or use one of the Bot Framework SDK templates for local develop‐ ment. The templates support the C#, JavaScript, and Python lan‐ guages with Java support in early preview at the time of writing. 

Test

To test conversational AI application, Microsoft provides the Bot Framework Emulator enabling developers to test conversations quickly and easily. We can also write unit tests using the Bot Frame‐ work SDK, which can focus on functionality testing of specific dia‐ logs. Once configured through the Azure portal, bot can be reached through a web chat interface, enabling broader testing by end users early in your development process. 

Publish 

When ready for your bot to be available on the web, either publish your bot to Azure or to your own web service or data center —wherever a normal web application can be hosted.

Connect 

Azure Bot Service does most of the work necessary to connect bots to a range of channels and devices. Configured through the Azure portal, you can connect your bots to Facebook Messenger, Slack, Microsoft Teams, Cortana, email, Telegram, Twilio, LINE, and other channels. You can also use Web Chat widgets to embed your bots in your websites or mobile applications. 

Evaluate

 Recordings of conversations between bots and users provide valua‐ ble business insights to help you evaluate your bot’s performance. At this phase, best practices include evaluating success metrics that you defined during the design phase, reviewing instrumentation logs, collecting user feedback, refining, and iterating. Bot Framework provides sample Application Insights queries and a Power BI dash‐ board to help you grasp the full breadth of your bot’s conversations with users and gain key insights into your bot’s health and behav


Virtual Assistants

Building on the Bot Framework SDK, Microsoft’s open source Vir‐ tual Assistant solution (available in C# and TypeScript) is a project template that encompasses the best practices for developing a bot on the Microsoft Azure platform. 



Building a conversational experience using the Virtual Assistant template requires the following resources: 


  • Azure Bot Registration (to configure Bot endpoint and channel configuration) 
  • Azure Web App (to host your Bot application) 
  • Azure Storage Account (to store transcripts) 
  • Azure Application Insights (telemetry) 
  • Azure Cosmos DB (Conversational State and User State—this can be swapped for Azure Storage for development purposes) 
  • Language Understanding 
  • QnA Maker (including Azure Cognitive Search and an Azure Web App)

 

Complete Control for Developers  

With Virtual Assistant, all aspects of the user experience are owned and controlled by you. This includes the branding, name, voice, per‐ sonality, responses, and avatar. Microsoft provides five chat person‐ alities based on the Azure Cognitive Service QnA Maker, enabling you to tailor the bot’s personality. The source code to the Virtual Assistant and supporting Skills are provided as samples for you to customize. Your Virtual Assistant will be deployed within your Azure subscription. Therefore, all data generated by your Assistant (questions asked, user behavior, etc.) is entirely contained within your Azure subscription. See Cognitive Services compliance and privacy details and the Azure section of the Trust Center for more information.

Prebuilt and Reusable 

Skills Common Virtual Assistant scenarios are provided as reusable Con‐ versational Skills and include tasks like finding nearby points of interest, checking off an item on a to-do list, and replying to an email. Skills—delivered in source code form—are fully customizable and consist of language models for multiple natural languages, dialogs, and integration code 

Flexible Integration and Contextual Awareness 

The Virtual Assistant architecture is flexible and can be integrated with existing speech or NLP capabilities, back-end systems, APIs, and devices to enable personalization and adapt responses as required for the users’ context. The Assistant can also be aware of the device or channel through which the user is communicating, which can be used to optimize the experience (e.g., voice versus text) and enable the user to switch between different channels if needed. 

Business Insights Captured and Distributed Bot Framework


 provides a rich set of out-of-the-box metrics ena‐ bling any conversational experience to collect data at the levels you desire, to let you understand better what your customers are asking and where you might have opportunities to improve the service