Categories
Opinion

Experience: Lessons from the 2023 AI Craze

As we integrate more AI assistants and chatbots into our workflows in 2024, one of the most valuable lessons I’ve learned from working closely with conversational systems like ChatGPT is that we need to approach them as collaborative, generative processes rather than expecting perfectly formulated final outputs right away.

The key is to have an iterative, back-and-forth conversation to get the best results. Rather than treating these AI systems as oracles that will produce complex solutions unaided in one go, think of having a dialogue where we provide context, examples and prompts to guide the conversation.

Most developers have probably already started using Github Copilot, Repl’s AI, or Cursor.so, and tons of web-based tools like windmill.dev, which all help by suggesting and inserting syntax and grammar, freeing me up to focus on higher level planning and architecture. By pasting in bug logs, snippets of code, and docs, I was able to quickly get useful code suggestions that would have taken much manual searching through documentation.

This example highlights a couple benefits of conversational guidance with AI: quickly solving the “needle in a haystack” problem of sifting through information, and also using the interactions as a learning aid for new developers.

Generative, Iterative Process

ChatGPT and other natural language AI tools represent a fundamental shift in how we interact with technology – rather than inputting precise queries and commands, we now have more flexible, conversational interfaces. This allows for a generative, iterative approach where both sides participate to produce the end result. Reminds me of my days learning about fuzzy search and teaching basic googling skills

The key is to have a back-and-forth dialogue, providing context and prompts to guide the AI. My go to for this is cursor.so when writing software. By copying bug logs and code snippets into the chat, Cursor’s chat (powered by GPT-4-1106-preview at time of writing) suggests relevant syntax and grammar and even entire functions (that are mostly working). This allows me to focus cognitive resources on higher level planning and program architecture rather than getting bogged down hunting for small syntax details in documentation.

The benefits of this conversational approach are twofold: first, it rapidly solves the classic “needle in a haystack” problem of locating some obscure piece of syntax from a vast documentation jungle. Second, it can aid learning by exposing developers to new patterns and approaches in Copilot’s code suggestions. Now that most tools are equipped with web search, you can simply follow-up and ask most bots to respond with the appropriate structure or give you more documentation to read on. 

The key is recognizing LLM chat interfaces like ChatGPT as conversational partners rather than just one-way input-output machines. By embracing this iterative mindset, we access so much more potential from AI. 

Tools for Different Purposes

While ChatGPT has exploded in popularity recently, it’s important to recognize that there are a range of AI assistants available, each with different strengths. Through my work, I’ve gained early access to tools like Anthropic and Claude that have expanded my perspective on AI’s capabilities.

For more open-ended creative tasks, I’ve found Anthropic to have very impressive natural language understanding and an intuitive conversational flow. The tool almost feels like chatting with a human teammate when brainstorming ideas or narrative content.

For generating synthetic media like images, video, and audio, Invoke.ai and Krea.ai take the top. While services like DALL-E 2 and Midjourney pioneered AI art, I love the “infinite canvas” feeling I get in Krea/Invoke when designing and iterating. 

My point is that while ChatGPT makes headlines, prompt engineering and conversation design are critical to effectively apply AI in real world applications. Focus on customizing prompts to take advantage of different tools’ strengths. Whether I’m drafting code in Cursor or writing a blog post with Anthropic ;), I design the conversation flow around what I’m trying to achieve.

The key is selecting the right tool for the job based on its capabilities, then guiding it with strategic prompts and examples. Rather than expecting any single AI assistant to excel at everything, prompt engineer. 

AI Cautions

As powerful as assistants have become, it’s important to be aware of some key limitations, especially when trying to get them to produce high-level plans and architecture beyond their current capabilities. Could this change in 2024? Autogen looks promising, but who knows. 

I learned this lesson the hard way when working on a coding project. After successfully using ChatGPT to generate small code snippets, I asked it to design the overall program architecture for me. Despite providing context and documentation, the result it produced was fragmented and incomplete and ultimately required major refactoring.

The key takeaways here are:

Be strategic in how you apply AI tools – understand their strengths and limitations

For complex tasks, be prepared to provide more upfront guidance through examples, documentation etc.

View it as a collaborative effort – don’t expect fully formed solutions unaided

I’m still very optimistic on AI’s potential, but learned through experience that we need to guide these models patiently rather than expecting fully autonomous reasoning capabilities beyond their training. The fruits come through collaboration.

Good luck out there!

Categories
Services

Chat Tools

Conversations, In Context

Thanks to the power of LLMs, bring functionality, productivity, and efficiency to where your teams chat. Whether you use Slack, Discord, Telegram, or something else, we can bring AI power to your group chats

Generative Documents

Build documentation where your teams chat.

Visuals On Demand

Use cutting edge generative AI to brainstorm logos, create diagrams, and more!

On-prem or Managed

Don't want to deal with development and maintenance? We'll host your software for a small fee.

Org Search

Omni-channel org information, on demand, up to date.

Try it out on your server!

Rise to the top

Increase Communication Efficiency

Bring your work to your conversations. Bots can be programmed to:

– understand thread/channel/organizational context and answer in meaningful ways.

– solve “needle in haystack” problems for massive organizations or teams with large knowledge bases

-search the internet from your  team’s chat

Team Support

Don’t spend all your time manually organizing your team’s information and collecting outside resources. 

  • execute commands and tasks with role-based permissions
  • brainstorm using generative AI right from your team’s chat space

FAQ's

We love this Github project, which is the foundation of most of the bots we develop for clients. 

Sure! If you’re not technical, feel free to add our development version of our bot to your server. 

Link to Gyle

If you need support, hop into our support server

 

With the help of our toolkits, we can build the perfect solution for you and your team. You can try out Gyle, our free ChatGPT powered bot on your server:

Link to Gyle

If you need support, hop into our support server

There are many Slack Integrations available. While we do not currently offer a public Slack integration, we can help develop one suited to your project’s needs.

At the time of writing, we are aware of this project

Categories
Case Study

LoomGPT

Instantly summarize hours long conversations

Right from ChatGPT

Don’t have time to watch the full Loom? 

Pop it in LoomGPT and summarize it!

Can’t remember that detail your colleague mentioned?

Ask LoomGPT!

Don’t search for needles, own the haystack!

Are you a developer?

Ping us for access on RapidAPI/Apify to the Loom Data Connection for more details. 

Categories
Current Trends

LangChain Tutorial: A Step-by-Step Python Crash Course

Langchain is a framework that allows you to create an application powered by a language model, in this langChain Tutorial Crash you will learn how to create an application powered by Large Language Models (LLMs) and we will cover all the essential features of this framework.

 

Overview:

  • Installation
  • LLMs
  • Prompt Templates
  • Chains
  • Agents and Tools
  • Memory
  • Document Loaders
  • Indexes

Installation :

`pip install langchain`

LLMs : 

LLMs are a kind of natural language processing (NLP) technology that uses deep learning to generate human-like language, if you are not familiar With LLms, you might hear about a popular example called: chatgpt.

Chatgpt is a language model developed by OpenAi and it was trained on a large amount of text data which allows it to understand the patterns and generate answers to the question

Langchain is a Python framework that provides different types of models for natural language processing, including LLMs, These LLMs are specifically designed to handle unstructured text data and provide answers to user queries. 

See all LLM providers.

				
					`pip install openai`

`import os
os.environ["OPENAI_API_KEY"] ="YOUR_OPENAI_TOKEN"
from langchain.llms import OpenAI


LLM = OpenAI(temperature=0.9)  # model_name="text-DaVinci-003"
text = "give me 5 python project "
print(LLM(text))
pip install huggingface_hub
os.environ["HUGGINGFACEHUB_API_TOKEN"] = "YOUR_HF_TOKEN"
from langchain import HuggingFaceHub
# https://huggingface.co/google/flan-t5-xl
llm = HuggingFaceHub(repo_id="google/flan-t5-xl", model_kwargs={"temperature":0, "max_length":64})
llm("Who won the FIFA World Cup in the year 1994?")`
				
			

Prompt Templates

what exactly are prompt templates for? 

I use prompt templates to structure my input to give it to the AI model, the reason is to guide the Ai model to output in a specific direction to make sure a more consistent and desired response.

 Why would I use this versus just chatting with the bot directly as a user like the ChatGPT UI?

The main difference between template and chat directly with chatgpt (like chatgpt ui) chatgpt UI allows for general conversation and is excellent for that purpose. Still, when you need more control, consistency, efficiency, or complexity that prompt templates come in handy right.

This feature allows developers to use PromptTemplates to construct prompts for user queries, which can then send to LLMs for processing

				
					llm("Can joe biden have a conversation with George Washington?")
				
			

Most of the time we don’t want to paste the question directly into the model like this
Output 

No, it is impossible for Barack Obama to have a conversation with George Washington as George Washington passed away in 1799.

How to write a better Prompt:

The better way to design the prompt is to Say

				
					prompt = """Question: Can joe biden have a conversation with George Washington?
Let's think step by step.
Answer: """
LLM(prompt)
output
				
			

No, Barack Obama and George Washington cannot have a conversation because George Washington is no longer alive.

PromptTemplates can help you accomplish this task:

				
					from langchain import PromptTemplate
template = """Question: {question}
Let's think step by step.
Answer: """
prompt = PromptTemplate(template=template, input_variables=["question"])
prompt.format(question="Can joe biden have a conversation with George Washington?")
llm(prompt)
				
			

I you want to run the code you will get the error because we can not pass the prompt directly to LLM

So we are going to use chain to pass to LLms

Chains

Chains offer a way to integrate diverse components into a unified application. For example, a chain can be created that takes user input, processes it using a PromptTemplate, and then feeds the structured response to a Language Learning Model (LLM). More intricate chains can be formed by interlinking numerous chains with other components.

				
					from langchain import LLMChain
llm_chain = LLMChain(prompt=prompt, llm=llm)
question = "What are the steps to start a successful online business?"
print(llm_chain.run(question))
				
			

Agents and Tools

Agents determine which actions to take and in what order. Agents can be incredibly powerful when used correctly. To successfully utilize agents, you should understand the following concepts:

Tool: A function that executes a specific task. This can be things like performing a Google Search, using another chain, or another task. See available Tools.

LLM: The language model powering the agent.

Agent: The agent to use. See also Agent Types.

				
					from langchain.agents import load_tools
from langchain.agents import initialize_agent
pip install Wikipedia
from langchain.llms import OpenAI
llm = OpenAI(temperature=0)
tools = load_tools(["Wikipedia", "LLM-math"], llm=llm)
agent = initialize_agent(tools, LLM, agent="zero-shot-react-description", verbose=True)
agent.run("Can you explain the concept of blockchain technology?”)
				
			

Memory

Memory refers to the concept of persisting state between calls of a chain or agent. LangChain provides a standard interface for memory, a collection of memory implementations, and examples of chains and agents that use memory.

Why Memory is Important?

Memory allows the model to maintain the context of a conversation. Without memory, each user prompt user would be processed in isolation

				
					from langchain import OpenAI, ConversationChainM

llm = OpenAI(temperature=0)
conversation = ConversationChain(llm=llm, verbose=True)

conversation.predict(input="Hi there!")
conversation.predict(input="Can we talk about BlockchainI?")
conversation.predict(input="I'm interested in Solona.")
				
			

Document Loaders

Combining language models with your own text data is a powerful way to differentiate them. The first step in doing this is to load the data into “Documents” – a fancy way of saying some pieces of text. The document loader is aimed at making this easy.

See all available Document Loaders.

				
					from langChain.document_loaders import NotionDirectoryLoader

loader = NotionDirectoryLoader("Notion_DB")

docs = loader.load()
				
			

Indexes

Indexes refer to ways to structure documents so that LLMs can best interact with them. This module contains utility functions for working with documents, different types of indexes, and then examples for using those indexes in chains.

  • Embeddings: Embeddings are a measure of the relatedness of text strings, and are represented with a vector (list) of floating point numbers.
  • Text Splitters: When you want to deal with long pieces of text, it is necessary to split up that text into chunks.
  • Vector databases store and organize special codes that represent the meaning and context of words, sentences, and documents in a way that helps search engines provide better and more relevant results. See available vectorstores.
				
					import requests

url = "https://raw.githubusercontent.com/hwchase17/langchain/master/docs/modules/state_of_the_union.txt"
res = requests.get(url)
with open("state_of_the_union.txt", "w") as f:
  f.write(res.text)


# Document Loader
from langchain.document_loaders import TextLoader
loader = TextLoader('./state_of_the_union.txt')
documents = loader.load()


# Text Splitter
from langchain.text_splitter import CharacterTextSplitter
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs = text_splitter.split_documents(documents)


pip install sentence_transformers


# Embeddings
from langchain.embeddings import HuggingFaceEmbeddings
embeddings = HuggingFaceEmbeddings()

#text = "This is a test document."
#query_result = embeddings.embed_query(text)
#doc_result = embeddings.embed_documents([text])


pip install faiss-cpu


from langchain.vectorstores import FAISS

db = FAISS.from_documents(docs, embeddings)

query = "What did the president say about Ketanji Brown Jackson"
docs = db.similarity_search(query)


print(docs[0].page_content)


# Save and load:
db.save_local("faiss_index")
new_db = FAISS.load_local("faiss_index", embeddings)
docs = new_db.similarity_search(query)
print(docs[0].page_content)

				
			

Conclusion : 

LangChain offers a comprehensive approach to building applications powered by generative models and LLMs. By integrating core concepts from data science, developers can create innovative ideas which are beyond traditional metrics by leveraging multiple components, and prompt templates.

As technology advances, more complex elements, including chat interfaces, are incorporated into agents, providing more comprehensive support in many different use cases.

Whether you’re developing chatbots, sentiment analysis tools, or any other NLP application, LangChain will be your best helper to unlock the full potential of your data. As advancements in Natural Language Processing (NLP) technology continue growing, platforms such as Langchain will only become more and more valuable

All the code will be found on GitHub

Reference:

https://python.langchain.com/en/latest/index.html

https://github.com/hwchase17/chat-langchain

Categories
FAQ

Where do I find my OpenAI API Key?

Many AI applications and tools need their users to obtain their own OpenAI API key. This key enables programmatic access to the OpenAI backend on behalf of the user, essentially “charging” an AI-powered tool.

 

Please note: at the time of writing, new users are given $ 5 USD in free “tokens” for 3 months. Afterwards, you will need a credit card to continue using any API keys. This is NOT the same as ChatGPT Plus.

Getting Started

To get started, go to the Open AI website. If you haven’t already created an account to use the ChatGPT UI, you can easily create an Open AI account by navigating to Developers -> API Reference (don’t worry about the code, we won’t be dealing with that today!)

If you’ve already set up an account and are signed in, you can ignore this part since you should see your profile icon and name in the top-right of the image in place of `Login` and `Sign up`.

Finding Your API Key

To get your API key, click on your name in the top right corner, which will display the drop-down menu. From the menu, select the “View API keys” option.

At this stage, you will see the option to `Create a new secret key at the centre. If you have any previously created API Keys, they will be visible here (you can only copy them once on creation, so be sure to copy it somewhere secure). If you don’t have an API key, click to get one.

Using Your API Key

Now that you have gotten your API key, you can give your applications and tools OpenAI power! Please be aware that some applications will consume more tokens than others. You can read more about how pricing is calculated on the OpenAI pricing page.

Categories
Current Trends

How to Scam People with AI

Just kidding


I thought I would take some time to go over some of the scams (either loosely or tightly) related to AI that have begun to surface. In the dawn of this new and exciting age, scams will likely continue to be on the rise in new forms.

I’ll go over some of the different scams I’ve spotted across the web. If you’ve got any more to share, drop a comment below!

👆Upwork Scamming

đŸ€–AI Proposals

In some cases, the lack of authenticity in the proposal may be especially [random adjective] when they use the AI equivalent of lorem ipsum in the text:

Bonus points if you also used an open-source image generation tool that contains all of the image generator prompts in the file name to make your attachments seem legit.

In another case, I was helping a client hire some UI help on Upwork to assist us with some design work. I usually have a pretty good knack for spotting good proposals, but this week really threw me for a loop.

The first sign to look for is checking the responses to questions that you post in the proposal. If they don’t respond to the answers well or use ChatGPT to generate responses, that’s a red flag to look for:

đŸ”ȘAccount Hijacking?

If the account is having issues, you won’t be able to see the profile of the contractor.

You can also spot potential issues if the account has been flagged if the contractor withdraws their proposal.

Lastly, when they come to the meeting, if their appearance doesn’t match the proposal, then you can be sure they are either a fake account, or the account has been compromised and they are fishing to pawn off a cheap project for a large amount:

Our conversation basically entailed an output that was NOT in spec with the proposal at all (I needed a simple automation setup using make.com or another glue tool, and they had obviously not read my proposal and were trying to sell an full-blown Application stack 😅

đŸ“șYouTube Scamming

While going over my home feed, a live stream with Elon Musk from OpenAI was airing! Curious to see what it was, I opened the video to find a QR in the corner that lead to a link that will allegedly change my life within minutes, according to a “screenshot” from Elon Musk overlaid on the video stream:

Let’s dig in, shall we?

  • Compromised or fake YouTube account? ✅
  • A single live stream with a relatively large amount of viewers? ✅
  • Does QR Code lead to “Tesla bonus dot live” (really)? ✅

I’ve reported 3 of these to YouTube, and they’ve been taken down within roughly 45 minutes. Stay sharp y’all!

🔍tl;dr

  • When hiring help on platforms like Upwork, it’s crucial to keep an eye out for red flags.
  • Examine the responses to your proposal questions; if they seem off or AI-generated, be cautious.
  • Watch for account hijacking signs, such as inaccessible profiles or withdrawn proposals.
  • During meetings, ensure the contractor’s appearance matches their proposal.
  • Watch out for fake live streams on YouTube. Check the authenticity of the channel for signs of account hijacking/bot views.
Courtesy of https://i.redd.it/dcz26dc7jlia1.png

By staying vigilant, you can avoid falling prey to scammers seeking to profit from your hard-earned cash. đŸ˜ŽđŸ’ŒđŸ’Ą

Follow us for more AI shenanigans. If you need help wrangling with this new world, call us for help automating your workflows IF and ELSE statements.

Categories
Current Trends

Demystifying AI for Business Leaders: Current Trends and Challenges Part 1

Everyone and their mother has something to say about AI these days. Whether you’re trying to garner media attention by signing a moratorium or making AI music videos, the entire world is focused on grappling with this horrifically powerful and sometimes down right silly and fun technology. Individuals and organizations both are looking towards how to best integrate AI into an existing project or start a totally new venture in this brave new world.

Here are some insights that can help you navigate the AI landscape with confidence.

Machine Dreams

Without providing an exhaustive list of examples (which can generally be found with a quick Google search), hallucination refers to AI responses that are incoherent given their training data. Unfortunately (or fortunately?) at the time of writing, the best practice of detecting hallucinations involves an actual human fact-checking the output of the AI.

Prepare for takeoff

Let me share a personal experience I had with the gpt-4 model while using it for data analysis. I provided it with a CSV file to run calculations, and as I checked the intermediary steps, I discovered that it had generated a completely fake dataset to “answer” my question. At first, it seemed to be on the right track, stating: I need to compare the two datasets to find the rows in the temp_sheet.tsv "Location" column that has corresponding cities in the demo.csv "City" column. However, things quickly went downhill from there.

```python
import pandas as pd

data1 = {'Name': ['John', 'Paul', 'Ringo', 'George'],
'Age': [20, 21, 22, 23]}

data2 = {'Name': ['John', 'Paul', 'George', 'Ringo'],
'Height': [180, 170, 175, 165]}

df1 = pd.DataFrame(data1)
df2 = pd.DataFrame(data2)

pd.merge(df1, df2, on='Name').head(3)

The Rise of Agent Behavior

With the launch of ChatGPT Plugins (most notably the ability to book flights) came the concept of “agent” behavior. An Intelligent Agent is essentially an AI that can receive environmental data and perform actions based on contextual information. In theory, it’s quite simple to “string” the inputs and outputs of different AI models to each other in a way that allows a main AI to interact with different assets in an agentic manner. LangChain is a popular open-source library for integrating this kind of behavior in your Python or JS project. There are many pre-built tools, clear examples in the documentation, and a highly-active developer community to help you integrate advanced AI usage into your project.

Bond, James Bond

Interested in implementing this AI solution for your business? Contact us for a consultation!

On a side note, OpenAI, if you happen to come across this article, I’m eagerly awaiting access to the plugin SDK! 😉

Data Leakage

Due to the nature of powering Large Language Models (LLM) and the advent of Reinforcement Learning from Human Feedback (RLHF), proprietary information has already been “accidentally” leaked into the verification and training data for OpenAI. This trend is likely to continue to get worse before it gets better as researchers and developers seek a balance between powering these feedback and resource-intensive engines while also securing user-submitted data. Unfortunately, the line between AI “power” and privacy is very thin due to the nature of how ML models work.

Data Leakage vs. Data Breaches

One way that organizations (such as Samsung) are combatting this is by developing in-house LLMs, given enough data, that allow their users to keep user prompts and interactions on internal servers. The downside here is that this relies on:

  • A large enough supply of data to fine-tune an open-source model
  • Enough users and verifiers to implement RLHF within organizational processes

Next Steps

Armed with these insights, I hope you can embark on your AI journey with greater confidence, even in this rapidly changing landscape. Remember the timeless machine learning mantra: “Garbage In = Garbage Out.” Always double-check your work and keep humans in the loop to minimize any potential negative side effects of utilizing AI in your project.

đŸ“» Stay tuned for Part 2 of this series, where we’ll dive into privacy and security issues related to AI. In the meantime, follow Automation Architech for more great content!

đŸ§™â€â™‚ïž We are AI application experts! If you want to collaborate on a project, drop an inquiry here, stop by our website, or shoot us a direct email.

📚 Check out some of our other content: