반응형
블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리


반응형

RNN (Recurrent Neural. Network, 순환신경망)

 

시계열(Sequencial)  데이터를 분석하기 위해 만든 딥러닝 모델. 

대량의 데이터 처리에 한계가 있었지만 그 한계를 극복하기 위해 아이디어를 짜 내면서 결국은 ChatGPT를 만든 Transformer 가 탄생하게 된다.

ChatGPT가 탄생하는 과정에서 빠뜨릴 수 없는 역사.

 

바로 그 RNN에 대해 알아보자.

 

https://youtu.be/k9i3bA1a-z0?si=rdACffh0JAeF5q4u

 

 

반응형


반응형

CNN (Convolutional Neural Network) - 합성곱 신경망

Dive into Deep Learning

 

이번 클립은 Deep Learning이 본격적으로 사용될 수 있는 계기를 만들었던 CNN 을 배워 봅니다.

1989년 벨 연구소에서 만든 LeNet 이 잠깐 사용되다가 잊혀 진 것을

2012년 토론토 대학교 팀이 AlexNet으로 부활을 시키고

그 팀 멤버 중 한명이 나중에 ChatGPT를 만들어 이 세상에 AI 붐을 일으킵니다.

 

AI 혁명에서 중요한 역할을 했던 CNN에 대해 배워 보겠습니다.

 

https://youtu.be/DwulX845Cvs?si=PT1MLWrh9GjxbSvg

 

저 위에 머리 약간 벗겨진 분이 일리야 서츠케버 (Ilya Sutskever) 입니다.

2012년 AlexNet 개발 팀 멤버였습니다.

바로 Deep Learning을 다시 보게 했던 그 유명한 국제 이미지넷 경연대회에서 1등한 팀입니다.

AlexNet 을 만든 팀이 세운 스타트업이 구글에 인수되면서 구글의 연구원으로 들어갑니다.

 

그가 바로 이세돌을 이겼던 알파고 개발을 진두 지휘했던 사람이죠.

 

그러다가 2015년에 인공 지능에 대한 견해 차이로 래리페이지와 갈등이 있었고 일론 머스크가 샘 올트먼과 함께 만든 OpenAI에 합류하게 됩니다. 일론 머스크가 적극적으로 영입에 앞장 섰다고 합니다.

 

거기서 그는 ChatGPT 및 GPT-4의 개발을 주도 했습니다.

 

그러다가 2023년 11월에 이사회가 샘 올트먼을 일방적으로 해고를 했는데요. 쿠테타에 비유 되기도 했죠.

그는 처음에는 이사회 편에 선 듯 했는데 나중에 임직원 90%가 샘 올트먼의 복귀를 요구하는 단체 행동을 벌이고 마이크로 소프트가 그들이 해고되거나 그만 둘 경우 모두 채용하겠다고 나서면서 직원들의 탄원서에 서명을 하게 됩니다. 그리고 사과도 했구요.

 

지금은 이사회에서는 사임을 했지만 OpenAI에서는 계속 일을 하고 있다고 합니다.

 

이런 흥미 진진한 AI의 딥러닝을 전세계에 첫선을 보이게 한 CNN에 대해 좀 더 깊이 한번 공부 해 보세요.

 

 

 

반응형


반응형

어제 2024년 2월 28일 IonQ 실적 발표가 있었습니다.

성적은 예상치 상단을 달성해서 괜찮았는데....

CTO로 있던 김정상 교수님이 사임을 하고 듀크대로 복귀 한다는 소식이 전해져 약간 충격적이었는데요.

 

이번에 seattlekdaily 라는 시애틀 지역 한인 신문에 시민 기자로서 참여 하기로 해서 첫 기사를 이 IonQ 실적 발표 소식을 전했습니다.

 

20여년 전 한국에 있을 때 지역신문에서 몇년 기자로 일 해 본 경력을 되살려 기사를 작성했는데... 기분이 좀 이상하네요.

 

https://www.seattlekdaily.com/news/articleView.html?idxno=7683

 

IonQ 실적발표, 매출 최고치 달성 예상...시애틀 지역 10억달러 투자 계획 - 시애틀코리안데일리

한국인 김정상 교수가 최대 주주이며 미국의 양자컴퓨터 분야에서 중요한 위치를 차지하고 있는 IonQ가 2월 28일 장마감 후 실적 발표를 하였다.이번 발표에서 2023년의 전체 매출이 2천 2백만달러

www.seattlekdaily.com

 

IonQ는 이번에 시애틀 지역에 제조 공장을 오픈하면서 제가 관심을 갖게 된 기업입니다.

AI를 이어서 퀀텀의 시대가 올 것인지 기대가 되네요.

한인인 김정상 교수가 창업멤버이고 최대 주주이기도 해서 더 관심이 갑니다.

 

 

앞으로도 쭉 지켜 볼 계획입니다.

반응형


반응형
Multilayer Perceptron
Deep Learning 이란 이름에 Deep 이 붙도록 만든 기술.
당시로서는 Linear Regression의 한계로 오랫동안 정체되어 있던 Machine learning계에 새로운 활력을 불어 넣었던 기술이다.
 
이번 클립에서는 Meltilayer Perceptron 에서 중요한 개념인 Non-linearity의 구현 방법과 Active Function 그리고 overfit을 해결하기 위한 Dropout 등의 기술에 대해 설명 한다.
 
ReLU, Sigmoid, Tanh 등 여러 활성화 함수들도 알아보고 Vanishing Gradient (기울기 소실) 문제를 해결하기 위해 이 Activation Function이 어떻게 사용되는지도 알아본다.

 

https://youtu.be/QwaPuylNYZI?si=48LoA2qxjCUlK4s8

 

 

 

 

 

 

 

반응형


반응형

AI 의 공부법

Linear Regression은 Deep Learning의 Learning 부분을 설명합니다.

Machine 이 스스로 Learning 하도록 만들었다는데 도대체 Machine 은 어떻게 스스로 Learning을 할까요?

똑똑한 AI 의 공부법을 배워 봅시다.

 

https://youtu.be/vBLJi3uYAOI?si=05hXIXtwkpQ9df5Q

 

내 생각에 AI 공부법은 무식하다고 생각합니다.

수천억개에 달하는 파라미터들 마다 하나하나 가중치 값을 바꿔 가면서 더하고 곱하고 미분하고 Softmax로 정규화해서 최선의 답을 찾아가니까요...

 

이번 유투브 강좌 에서는 AI 가 공부하는 방법의 가장 기본이 되는 Deep Learning 의 시작인 Linear Regression 에 대해 알아 봅니다.

 

 

 

 

 

 

 

 

 

반응형


반응형

양자컴퓨터 분야에서 두각을 보이고 있는 IonQ 가 내가 사는 워싱턴 주에 공장을 세웠다고 한다.
시애틀 옆에 Bothell 이라는 곳이 있는데 이곳에 며칠전 공장을 오픈 했다.

양자 컴퓨터는 아직 최소한 5년은 더 기다려야 뭔가 가시적인 성과가 나올거라고 예상하고 있었는데….

양자 컴퓨터를 만드는 공장을 오픈 했다니..
그리고 벌써 미국 공군으로 부터 주문도 받았다고 한다.

생각보다 훨씬 빨리 진행되는 것 같다.

지금 AI 를 공부하고 있는데 양자 컴퓨터도 관심이 있어서 가끔 들여다 보는데…
둘 다 통계와 확률이 핵심적인 개념이라서 AI 를 training 시키는데 양자 컴퓨터를 사용하면 엄청난 시너지가 나올것 같다는 생각을 하고 있다.

그런 양자컴퓨터의 최선도 기업중 하나인 IonQ 가 내가 사는곳 근처에 공장을 지었다고 하니…
더 관심이 간다.

https://finance.yahoo.com/news/ionq-opens-doors-first-dedicated-224000490.html

 

IonQ Opens Doors to First Dedicated Quantum Computing Manufacturing Facility in the U.S.

COLLEGE PARK, Md., February 15, 2024--IonQ (NYSE: IONQ), a leader in the quantum computing industry, today announced the opening of the United States’ first quantum computing manufacturing facility, located in Bothell, Washington, a suburb of Seattle. As

finance.yahoo.com

 

 

반응형


반응형

Basic of AI (Artificial Intelligence), ML (Machine learning) and DL (Deep Learning)

 

Deep Learning Fundamental 강의 두번째 클립 입니다.

Dive into Deep learning 을 공부하고 난 후 Deep Learning 관련 내용을 정리했습니다.

 

이번 클립에서는 Machine Learning은 무엇을 배우기 위한 시스템인지를 알아 봅니다.

기계가 무엇을 배운다면 그 부분에서 일을 하던 인간들을 대체할 것입니다.

그러면 그 사람들은 직업을 잃을 가능성이 커집니다.

 

기계는 과연 Machine Learning을 통해서 무엇을 배우는 걸까요?

 

더불어서 AI, ML 그리고 DL이 무엇인지도 간략하게 살펴 봅니다.

 

https://youtu.be/Xkoh-IYqdK4?si=6CBagL2ViupS48cA

 

 

PPT (Korean) : https://docs.google.com/presentation/d/15KNzGnSnJx_4ToSBM2MrHiC2q5MiVe0plOs7f3NJuWM/edit?usp=sharing

 

PPT (English) : https://docs.google.com/presentation/d/1F4qxSAv9g13de99rS8fcp4e1LCfrILq8QaahXCPx1Pw/edit?usp=sharing

 

My AI Web Application Portfolio web site https://catchupai.streamlit.app/

 

Catchup AI Portfolio

This app was built in Streamlit! Check it out and visit https://streamlit.io for more awesome community apps. 🎈

catchupai.streamlit.app

 

 

 

반응형


반응형

시애틀이 있는 워싱턴 주에서는 2월이나 3월중에 딱 하루만 허용되는 재미있는 낚시가 있다.

낚시대도 필요 없고 잠자리 채만 있으면 된다.

 

이 때 바다에서 강으로 올라오는 바다 빙어를 잡는 일이다.

한뼘 크기의 양미리를 닮은 이 고기는 구워 먹으면 고소하다.

비늘 손질할 필요도 없고 대가리며 내장이며 다 먹어도 된다.

 

작년엔 개체수 보호를 위해 오픈을 하지 않았는데 올해는 2월 15일 목요일 오픈을 했다.

 

https://youtu.be/XxpZSv4GZho?si=meO2i7gEKX69fmqG

 

운 좋으면 3월에 하루 더 오픈 할 수 있다고 한다.

 

미국 서북쪽에 있는 워싱턴 주는 겨울에 영하로 내려가는 일이 며칠 안 된다.

그래서 눈이 오는 날도 별로 없다.

 

근데 어제는 폭설이 내렸다.

 

밤 12시까지 AI 공부를 하다가 우연히 창밖을 봤는데 애기 주먹만한 눈송이가 떨어지고 있었다.

 

https://youtu.be/jju8z-UUVuY?si=KSxWMg3OMO7DYO_w

 

잠자리채로 바다 빙어를 낚을 수 있는 강은 우리 집에서 남쪽에 있는데 다행히 거기는 기온이 우리 동네 보다 높아서 눈이 내리지는 않아서 별 어려움 없이 뜰채 낚시를 할 수 있었다.

 

다만 재작년 보다 개체수가 많이 줄어서 거의 3시간 동안 물속에 있었다.

거의 하반신 신경이 마비 될 정도로 차가운 물속에 오래 있었다.

 

 

하지만 푸짐한 바다 빙어를 보면.... 그리고 고소한 맛을 맛 보면 잘 했다는 생각이 든다....

 

이제 다시 AI 공부에 매진할 때이다....

 

화이팅.....

반응형

LC-Modules-Agents Quickstart

2024. 2. 14. 12:41 | Posted by 솔웅


반응형

https://python.langchain.com/docs/modules/agents/quick_start

 

Quickstart | 🦜️🔗 Langchain

quickstart}

python.langchain.com

 

 

 

Quickstart

To best understand the agent framework, let’s build an agent that has two tools: one to look things up online, and one to look up specific data that we’ve loaded into a index.

 

에이전트 프레임워크를 가장 잘 이해하기 위해 두 가지 도구가 있는 에이전트를 구축해 보겠습니다. 하나는 온라인으로 항목을 조회하는 도구이고 다른 하나는 인덱스에 로드한 특정 데이터를 조회하는 도구입니다.

 

This will assume knowledge of LLMs and retrieval so if you haven’t already explored those sections, it is recommended you do so.

 

이는 LLM 및 검색에 대한 지식을 가정하므로 해당 섹션을 아직 탐색하지 않았다면 탐색하는 것이 좋습니다.

 

Setup: LangSmith

By definition, agents take a self-determined, input-dependent sequence of steps before returning a user-facing output. This makes debugging these systems particularly tricky, and observability particularly important. LangSmith is especially useful for such cases.

 

정의에 따르면 에이전트는 사용자에게 표시되는 출력을 반환하기 전에 입력에 따라 자체 결정된 일련의 단계를 수행합니다. 이로 인해 이러한 시스템을 디버깅하는 것이 특히 까다로워지고 관찰 가능성이 특히 중요해집니다. LangSmith는 이러한 경우에 특히 유용합니다.

 

When building with LangChain, all steps will automatically be traced in LangSmith. To set up LangSmith we just need set the following environment variables:

 

LangChain으로 구축할 때 모든 단계는 LangSmith에서 자동으로 추적됩니다. LangSmith를 설정하려면 다음 환경 변수만 설정하면 됩니다.

 

export LANGCHAIN_TRACING_V2="true"
export LANGCHAIN_API_KEY="<your-api-key>"

 

 

Define tools

We first need to create the tools we want to use. We will use two tools: Tavily (to search online) and then a retriever over a local index we will create

 

먼저 사용하려는 도구를 만들어야 합니다. 우리는 두 가지 도구를 사용할 것입니다: Tavily(온라인 검색용)와 우리가 생성할 로컬 인덱스에 대한 검색기

 

Tavily

We have a built-in tool in LangChain to easily use Tavily search engine as tool. Note that this requires an API key - they have a free tier, but if you don’t have one or don’t want to create one, you can always ignore this step.

 

우리는 Tavily 검색 엔진을 도구로 쉽게 사용할 수 있도록 LangChain에 내장된 도구를 가지고 있습니다. 이를 위해서는 API 키가 필요합니다. 무료 등급이 있지만 API 키가 없거나 생성하고 싶지 않은 경우 언제든지 이 단계를 무시할 수 있습니다.

 

Once you create your API key, you will need to export that as:

 

API 키를 생성한 후에는 이를 다음과 같이 내보내야 합니다.

 

export TAVILY_API_KEY="..."
from langchain_community.tools.tavily_search import TavilySearchResults
search = TavilySearchResults()
search.invoke("what is the weather in SF")
[{'url': 'https://www.metoffice.gov.uk/weather/forecast/9q8yym8kr',
  'content': 'Thu 11 Jan Thu 11 Jan Seven day forecast for San Francisco  San Francisco (United States of America) weather Find a forecast  Sat 6 Jan Sat 6 Jan Sun 7 Jan Sun 7 Jan Mon 8 Jan Mon 8 Jan Tue 9 Jan Tue 9 Jan Wed 10 Jan Wed 10 Jan Thu 11 Jan  Find a forecast Please choose your location from the nearest places to : Forecast days Today Today Sat 6 Jan Sat 6 JanSan Francisco 7 day weather forecast including weather warnings, temperature, rain, wind, visibility, humidity and UV ... (11 January 2024) Time 00:00 01:00 02:00 03:00 04:00 05:00 06:00 07:00 08:00 09:00 10:00 11:00 12:00 ... Oakland Int. 11.5 miles; San Francisco International 11.5 miles; Corte Madera 12.3 miles; Redwood City 23.4 miles;'},
 {'url': 'https://www.latimes.com/travel/story/2024-01-11/east-brother-light-station-lighthouse-california',
  'content': "May 18, 2023  Jan. 4, 2024 Subscribe for unlimited accessSite Map Follow Us MORE FROM THE L.A. TIMES  Jan. 8, 2024 Travel & Experiences This must be Elysian Valley (a.k.a. Frogtown) Jan. 5, 2024 Food  June 30, 2023The East Brother Light Station in the San Francisco Bay is not a destination for everyone. ... Jan. 11, 2024 3 AM PT ... Champagne and hors d'oeuvres are served in late afternoon — outdoors if ..."}]

 

Retriever

We will also create a retriever over some data of our own. For a deeper explanation of each step here, see this section.

 

우리는 또한 우리 자신의 일부 데이터에 대한 검색기를 만들 것입니다. 각 단계에 대한 자세한 설명은 이 섹션을 참조하세요.

 

from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.document_loaders import WebBaseLoader
from langchain_community.vectorstores import FAISS
from langchain_openai import OpenAIEmbeddings

loader = WebBaseLoader("https://docs.smith.langchain.com/overview")
docs = loader.load()
documents = RecursiveCharacterTextSplitter(
    chunk_size=1000, chunk_overlap=200
).split_documents(docs)
vector = FAISS.from_documents(documents, OpenAIEmbeddings())
retriever = vector.as_retriever()
retriever.get_relevant_documents("how to upload a dataset")[0]
Document(page_content="dataset uploading.Once we have a dataset, how can we use it to test changes to a prompt or chain? The most basic approach is to run the chain over the data points and visualize the outputs. Despite technological advancements, there still is no substitute for looking at outputs by eye. Currently, running the chain over the data points needs to be done client-side. The LangSmith client makes it easy to pull down a dataset and then run a chain over them, logging the results to a new project associated with the dataset. From there, you can review them. We've made it easy to assign feedback to runs and mark them as correct or incorrect directly in the web app, displaying aggregate statistics for each test project.We also make it easier to evaluate these runs. To that end, we've added a set of evaluators to the open-source LangChain library. These evaluators can be specified when initiating a test run and will evaluate the results once the test run completes. If we’re being honest, most of", metadata={'source': 'https://docs.smith.langchain.com/overview', 'title': 'LangSmith Overview and User Guide | 🦜️🛠️ LangSmith', 'description': 'Building reliable LLM applications can be challenging. LangChain simplifies the initial setup, but there is still work needed to bring the performance of prompts, chains and agents up the level where they are reliable enough to be used in production.', 'language': 'en'})

 

Now that we have populated our index that we will do doing retrieval over, we can easily turn it into a tool (the format needed for an agent to properly use it)

 

이제 검색을 수행할 인덱스를 채웠으므로 이를 도구(에이전트가 올바르게 사용하는 데 필요한 형식)로 쉽게 전환할 수 있습니다.

 

from langchain.tools.retriever import create_retriever_tool
retriever_tool = create_retriever_tool(
    retriever,
    "langsmith_search",
    "Search for information about LangSmith. For any questions about LangSmith, you must use this tool!",
)

 

 

Tools

Now that we have created both, we can create a list of tools that we will use downstream.

 

이제 두 가지를 모두 만들었으므로 다운스트림에서 사용할 도구 목록을 만들 수 있습니다.

 

tools = [search, retriever_tool]

 

 

Create the agent

Now that we have defined the tools, we can create the agent. We will be using an OpenAI Functions agent - for more information on this type of agent, as well as other options, see this guide

 

Agent Types | 🦜️🔗 Langchain

This categorizes all the available agents along a few dimensions.

python.langchain.com

 

이제 도구를 정의했으므로 에이전트를 만들 수 있습니다. OpenAI Functions 에이전트를 사용할 것입니다. 이러한 유형의 에이전트와 기타 옵션에 대한 자세한 내용은 이 가이드를 참조하세요.

 

First, we choose the LLM we want to be guiding the agent.

 

먼저 에이전트를 안내할 LLM을 선택합니다.

 

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)

 

Next, we choose the prompt we want to use to guide the agent.

 

다음으로 상담원을 안내하는 데 사용할 프롬프트를 선택합니다.

 

 

If you want to see the contents of this prompt and have access to LangSmith, you can go to:

 

이 프롬프트의 내용을 보고 LangSmith에 액세스하려면 다음으로 이동하세요.

 

https://smith.langchain.com/hub/hwchase17/openai-functions-agent

 

LangSmith

 

smith.langchain.com

 

from langchain import hub

# Get the prompt to use - you can modify this!
prompt = hub.pull("hwchase17/openai-functions-agent")
prompt.messages

 

[SystemMessagePromptTemplate(prompt=PromptTemplate(input_variables=[], template='You are a helpful assistant')),
 MessagesPlaceholder(variable_name='chat_history', optional=True),
 HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=['input'], template='{input}')),
 MessagesPlaceholder(variable_name='agent_scratchpad')]

 

Now, we can initalize the agent with the LLM, the prompt, and the tools. The agent is responsible for taking in input and deciding what actions to take. Crucially, the Agent does not execute those actions - that is done by the AgentExecutor (next step). For more information about how to think about these components, see our conceptual guide

 

Concepts | 🦜️🔗 Langchain

The core idea of agents is to use a language model to choose a sequence of actions to take.

python.langchain.com

 

 

이제 LLM, 프롬프트 및 도구를 사용하여 에이전트를 초기화할 수 있습니다. 에이전트는 입력을 받아들이고 어떤 조치를 취할지 결정하는 역할을 담당합니다. 결정적으로 에이전트는 이러한 작업을 실행하지 않습니다. 이는 AgentExecutor(다음 단계)에 의해 수행됩니다. 이러한 구성 요소에 대해 생각하는 방법에 대한 자세한 내용은 개념 가이드를 참조하세요.

 

from langchain.agents import create_openai_functions_agent

agent = create_openai_functions_agent(llm, tools, prompt)

 

Finally, we combine the agent (the brains) with the tools inside the AgentExecutor (which will repeatedly call the agent and execute tools). For more information about how to think about these components, see our conceptual guide

 

Concepts | 🦜️🔗 Langchain

The core idea of agents is to use a language model to choose a sequence of actions to take.

python.langchain.com

 

마지막으로 에이전트(브레인)를 AgentExecutor 내부 도구(반복적으로 에이전트를 호출하고 도구를 실행함)와 결합합니다. 이러한 구성 요소에 대해 생각하는 방법에 대한 자세한 내용은 개념 가이드를 참조하세요.

 

from langchain.agents import AgentExecutor

agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

 

Run the agent

We can now run the agent on a few queries! Note that for now, these are all stateless queries (it won’t remember previous interactions).

 

이제 몇 가지 쿼리에 대해 에이전트를 실행할 수 있습니다! 현재로서는 이는 모두 상태 비저장 쿼리입니다(이전 상호 작용을 기억하지 않음).

 

agent_executor.invoke({"input": "hi!"})

 


> Entering new AgentExecutor chain...
Hello! How can I assist you today?

> Finished chain.

 

{'input': 'hi!', 'output': 'Hello! How can I assist you today?'}

 

agent_executor.invoke({"input": "how can langsmith help with testing?"})

 


> Entering new AgentExecutor chain...

Invoking: `langsmith_search` with `{'query': 'LangSmith testing'}`


[Document(page_content='LangSmith Overview and User Guide | 🦜️🛠️ LangSmith', metadata={'source': 'https://docs.smith.langchain.com/overview', 'title': 'LangSmith Overview and User Guide | 🦜️🛠️ LangSmith', 'description': 'Building reliable LLM applications can be challenging. LangChain simplifies the initial setup, but there is still work needed to bring the performance of prompts, chains and agents up the level where they are reliable enough to be used in production.', 'language': 'en'}), Document(page_content='Skip to main content🦜️🛠️ LangSmith DocsPython DocsJS/TS DocsSearchGo to AppLangSmithOverviewTracingTesting & EvaluationOrganizationsHubLangSmith CookbookOverviewOn this pageLangSmith Overview and User GuideBuilding reliable LLM applications can be challenging. LangChain simplifies the initial setup, but there is still work needed to bring the performance of prompts, chains and agents up the level where they are reliable enough to be used in production.Over the past two months, we at LangChain have been building and using LangSmith with the goal of bridging this gap. This is our tactical user guide to outline effective ways to use LangSmith and maximize its benefits.On by default\u200bAt LangChain, all of us have LangSmith’s tracing running in the background by default. On the Python side, this is achieved by setting environment variables, which we establish whenever we launch a virtual environment or open our bash shell and leave them set. The same principle applies to most JavaScript', metadata={'source': 'https://docs.smith.langchain.com/overview', 'title': 'LangSmith Overview and User Guide | 🦜️🛠️ LangSmith', 'description': 'Building reliable LLM applications can be challenging. LangChain simplifies the initial setup, but there is still work needed to bring the performance of prompts, chains and agents up the level where they are reliable enough to be used in production.', 'language': 'en'}), Document(page_content='You can also quickly edit examples and add them to datasets to expand the surface area of your evaluation sets or to fine-tune a model for improved quality or reduced costs.Monitoring\u200bAfter all this, your app might finally ready to go in production. LangSmith can also be used to monitor your application in much the same way that you used for debugging. You can log all traces, visualize latency and token usage statistics, and troubleshoot specific issues as they arise. Each run can also be assigned string tags or key-value metadata, allowing you to attach correlation ids or AB test variants, and filter runs accordingly.We’ve also made it possible to associate feedback programmatically with runs. This means that if your application has a thumbs up/down button on it, you can use that to log feedback back to LangSmith. This can be used to track performance over time and pinpoint under performing data points, which you can subsequently add to a dataset for future testing — mirroring the', metadata={'source': 'https://docs.smith.langchain.com/overview', 'title': 'LangSmith Overview and User Guide | 🦜️🛠️ LangSmith', 'description': 'Building reliable LLM applications can be challenging. LangChain simplifies the initial setup, but there is still work needed to bring the performance of prompts, chains and agents up the level where they are reliable enough to be used in production.', 'language': 'en'}), Document(page_content='inputs, and see what happens. At some point though, our application is performing\nwell and we want to be more rigorous about testing changes. We can use a dataset\nthat we’ve constructed along the way (see above). Alternatively, we could spend some\ntime constructing a small dataset by hand. For these situations, LangSmith simplifies', metadata={'source': 'https://docs.smith.langchain.com/overview', 'title': 'LangSmith Overview and User Guide | 🦜️🛠️ LangSmith', 'description': 'Building reliable LLM applications can be challenging. LangChain simplifies the initial setup, but there is still work needed to bring the performance of prompts, chains and agents up the level where they are reliable enough to be used in production.', 'language': 'en'})]LangSmith can help with testing in several ways. Here are some ways LangSmith can assist with testing:

1. Tracing: LangSmith provides tracing capabilities that can be used to monitor and debug your application during testing. You can log all traces, visualize latency and token usage statistics, and troubleshoot specific issues as they arise.

2. Evaluation: LangSmith allows you to quickly edit examples and add them to datasets to expand the surface area of your evaluation sets. This can help you test and fine-tune your models for improved quality or reduced costs.

3. Monitoring: Once your application is ready for production, LangSmith can be used to monitor your application. You can log feedback programmatically with runs, track performance over time, and pinpoint underperforming data points. This information can be used to improve your application and add to datasets for future testing.

4. Rigorous Testing: When your application is performing well and you want to be more rigorous about testing changes, LangSmith can simplify the process. You can use existing datasets or construct small datasets by hand to test different scenarios and evaluate the performance of your application.

For more detailed information on how to use LangSmith for testing, you can refer to the [LangSmith Overview and User Guide](https://docs.smith.langchain.com/overview).

> Finished chain.

 

{'input': 'how can langsmith help with testing?',
 'output': 'LangSmith can help with testing in several ways. Here are some ways LangSmith can assist with testing:\n\n1. Tracing: LangSmith provides tracing capabilities that can be used to monitor and debug your application during testing. You can log all traces, visualize latency and token usage statistics, and troubleshoot specific issues as they arise.\n\n2. Evaluation: LangSmith allows you to quickly edit examples and add them to datasets to expand the surface area of your evaluation sets. This can help you test and fine-tune your models for improved quality or reduced costs.\n\n3. Monitoring: Once your application is ready for production, LangSmith can be used to monitor your application. You can log feedback programmatically with runs, track performance over time, and pinpoint underperforming data points. This information can be used to improve your application and add to datasets for future testing.\n\n4. Rigorous Testing: When your application is performing well and you want to be more rigorous about testing changes, LangSmith can simplify the process. You can use existing datasets or construct small datasets by hand to test different scenarios and evaluate the performance of your application.\n\nFor more detailed information on how to use LangSmith for testing, you can refer to the [LangSmith Overview and User Guide](https://docs.smith.langchain.com/overview).'}

 

 

Adding in memory

 

As mentioned earlier, this agent is stateless. This means it does not remember previous interactions. To give it memory we need to pass in previous chat_history. Note: it needs to be called chat_history because of the prompt we are using. If we use a different prompt, we could change the variable name

 

앞서 언급했듯이 이 에이전트는 Stateless입니다. 이는 이전 상호작용을 기억하지 못한다는 것을 의미합니다. 메모리를 제공하려면 이전 chat_history를 전달해야 합니다. 참고: 우리가 사용하는 프롬프트 때문에 chat_history라고 불러야 합니다. 다른 프롬프트를 사용하면 변수 이름을 변경할 수 있습니다.

 

# Here we pass in an empty list of messages for chat_history because it is the first message in the chat
agent_executor.invoke({"input": "hi! my name is bob", "chat_history": []})

> Entering new AgentExecutor chain...
Hello Bob! How can I assist you today?

> Finished chain.
{'input': 'hi! my name is bob',
 'chat_history': [],
 'output': 'Hello Bob! How can I assist you today?'}
from langchain_core.messages import AIMessage, HumanMessage
agent_executor.invoke(
    {
        "chat_history": [
            HumanMessage(content="hi! my name is bob"),
            AIMessage(content="Hello Bob! How can I assist you today?"),
        ],
        "input": "what's my name?",
    }
)

 


> Entering new AgentExecutor chain...
Your name is Bob.

> Finished chain.
{'chat_history': [HumanMessage(content='hi! my name is bob'),
  AIMessage(content='Hello Bob! How can I assist you today?')],
 'input': "what's my name?",
 'output': 'Your name is Bob.'}

 

 

If we want to keep track of these messages automatically, we can wrap this in a RunnableWithMessageHistory. For more information on how to use this, see this guide

 

Add message history (memory) | 🦜️🔗 Langchain

The RunnableWithMessageHistory let us add message history to certain

python.langchain.com

 

이러한 메시지를 자동으로 추적하려면 이를 RunnableWithMessageHistory로 래핑할 수 있습니다. 이를 사용하는 방법에 대한 자세한 내용은 이 가이드를 참조하세요.

 

from langchain_community.chat_message_histories import ChatMessageHistory
from langchain_core.runnables.history import RunnableWithMessageHistory
message_history = ChatMessageHistory()
agent_with_chat_history = RunnableWithMessageHistory(
    agent_executor,
    # This is needed because in most real world scenarios, a session id is needed
    # It isn't really used here because we are using a simple in memory ChatMessageHistory
    lambda session_id: message_history,
    input_messages_key="input",
    history_messages_key="chat_history",
)
agent_with_chat_history.invoke(
    {"input": "hi! I'm bob"},
    # This is needed because in most real world scenarios, a session id is needed
    # It isn't really used here because we are using a simple in memory ChatMessageHistory
    config={"configurable": {"session_id": "<foo>"}},
)

> Entering new AgentExecutor chain...
Hello Bob! How can I assist you today?

> Finished chain.
{'input': "hi! I'm bob",
 'chat_history': [],
 'output': 'Hello Bob! How can I assist you today?'}
agent_with_chat_history.invoke(
    {"input": "what's my name?"},
    # This is needed because in most real world scenarios, a session id is needed
    # It isn't really used here because we are using a simple in memory ChatMessageHistory
    config={"configurable": {"session_id": "<foo>"}},
)

> Entering new AgentExecutor chain...
Your name is Bob.

> Finished chain.
{'input': "what's my name?",
 'chat_history': [HumanMessage(content="hi! I'm bob"),
  AIMessage(content='Hello Bob! How can I assist you today?')],
 'output': 'Your name is Bob.'}

 

Conclusion

That’s a wrap! In this quick start we covered how to create a simple agent. Agents are a complex topic, and there’s lot to learn! Head back to the main agent page to find more resources on conceptual guides, different types of agents, how to create custom tools, and more!

 

마무리입니다! 이 빠른 시작에서는 간단한 에이전트를 만드는 방법을 다루었습니다. 에이전트는 복잡한 주제이며 배울 것이 많습니다! 기본 에이전트 페이지로 돌아가서 개념 가이드, 다양한 유형의 에이전트, 사용자 정의 도구를 만드는 방법 등에 대한 추가 리소스를 찾아보세요!

반응형


반응형

시애틀에서 100키로미터 쯤 떨어진 곳에 Olympia 라는 곳이 있습니다.

그곳에서 1년동안 은둔 생활을 하면서 틈틈이 AI를 공부했습니다.

 

그 공부한 내용을 정리하는 의미에서 유투브 채널을 만들 결심을 했습니다.

드디어 첫번째 클립이 업로드 됐어요.

 

채널 이름은 CatchupAI (https://www.youtube.com/@catchupai).

AI 따라잡기 입니다.

10년전 미국에 와서 IT 기술 따라잡기라는 이름으로 이 티스토리 블로그 활동을 처음 시작했는데요.

이제 AI 따라잡기가 다시 시작 됐습니다.

 

https://youtu.be/G_X-NtEZ0us?si=heJ5Vz1pa2S9qa7T

 

 

작년 중순에 시애틀 지역 한인 IT 엔지니어 모임인 창발이라는 곳에서 AI Study Group에 가입해서 3개월간 Deep Learning Fundamental을 공부 했었어요.

교재는 Dive into Deep Learning 이었구요.

 

그 내용을 기반으로 Deep Learning Fundamental 을 주제로 PPT를 만들었었습니다.

 

한두번 이 PPT를 가지고 발표 할 기회가 있었는데요.

 

그 내용을 유투브로 만들었습니다.

 

그 중 첫번째 클립이 업로드 된 겁니다.

많은 시청 바라구요. 구독과 좋아요 꼭 부탁 드립니다.

 

 

이 클립은 첫번째 Introduce (Target) 과 추가로 인간과 AI 가 이 세상을 인식하는 방법을 비교하는 내용도 있습니다.

 

 

AI는 이 세상을 어떻게 이해하고 그것이 인간과 무엇이 다르고 무엇이 같은지 알려 드립니다.

대부분 같지만 약간 다른점이 있는데 그것이 무엇인지 위 유투브 보시고 확인해 보세요.

 

그 다른점 때문에 생성형 AI의 단점인 Hallucination이 발생하게 되는 겁니다.

 

 

그리고 AI 는 어떻게 학습을 하는지 아주 간단한 예제로 AI가 학습하는 과정을 그대로 따라해 봤습니다.

Back propagation이 무엇인지 그리고 그 방법 때문에 ChatGPT 같은 아주 놀라운 성능의 AI 제품이 나올 수 있었지만 동시에 Freshness problem이라는 한계점도 가지고 있다는 점.

 

위 유투브 내용을 보시면 들어 보지 못했던 흥미로운 점을 이해하실 수 있으실 거예요.

 

시간과 열정을 가지고 열심히 공부해서 나름대로 이해하고 깨달은 내용을 정리했습니다.

많은 관심과 구독 좋아요 부탁드립니다.

 

Note: Deep Learning Fundamental 강좌가 끝나면 지금 공부하고 있는 AI Web App 개발과 관련된 내용도 이어질 예정입니다.

 

제가 지금 개발하고 있는 저만의 AI Web App Portfolio는 아래 웹사이트로 가면 보실 수 있습니다.

 

https://catchupai.streamlit.app/

 

Catchup AI Portfolio

This app was built in Streamlit! Check it out and visit https://streamlit.io for more awesome community apps. 🎈

catchupai.streamlit.app

 

반응형