Skip to Content
엔터프라이즈 Java 개발을 위한 응용 AI (Korean Edition)
book

엔터프라이즈 Java 개발을 위한 응용 AI (Korean Edition)

by Alex Soto Bueno, Markus Eisele, Natale Vinto
November 2025
Beginner to intermediate
430 pages
6h 48m
Korean
O'Reilly Media, Inc.
Content preview from 엔터프라이즈 Java 개발을 위한 응용 AI (Korean Edition)

제9장. 벡터 임베딩과 저장소

이 작품은 AI를 사용하여 번역되었습니다. 여러분의 피드백과 의견을 환영합니다: translation-feedback@oreilly.com

이 시점에서 여러분은 DJL 라이브러리를 사용하여 모델을 추론하고 LangChain4j로 이를 활용하는 방법을 알고 있습니다. 또한 제3장에서는 AI 애플리케이션 개발 시 핵심 개념인 RAG를 소개했습니다.

RAG는 유사도 검색을 위해 벡터 임베딩 계산과 수학(코사인 유사도, 제곱 유클리드 거리 등)에 크게 의존합니다. 이 장에서는 벡터 임베딩의 다음과 같은 핵심 측면을 학습하게 됩니다:

  • DJL을 이용한 임베딩 계산

  • 프로세스 내 LangChain4j를 이용한 임베딩 계산

  • 원격 모델을 이용한 임베딩 계산

  • 벡터 저장소를 활용한 고급 검색 기능 구현 및 캐싱

  • RAG를 위한 문서 준비 및 수집

  • 간단한 RAG 구현

  • 고급 RAG 사용(QueryRouter, ReRanking 등)

이 장을 마치면 다양한 접근법으로 벡터를 계산하는 방법을 알게 되며, RAG 관점뿐만 아니라 다른 활용 사례에서도 임베딩을 깊이 이해하게 될 것입니다. 또한 고차원 벡터를 시각화하거나 자동 분류를 위한 클러스터링 알고리즘도 소개합니다.

벡터 임베딩 계산

에서 다시 한번 상기하자면, 벡터 임베딩 (또는 임베딩)은 텍스트, 오디오, 이미지 같은 요소를 설명하는 데 사용되는 숫자 배열로, 의미적 관계를 벡터 형태로 포착합니다. 예를 들어 "cat"은 [1, 0, 1] 벡터를 가질 수 있고, "car"는 [7, 3, 8] 벡터를 가질 수 있습니다.

이 계산은 텍스트를 벡터로 변환하는 특수 모델을 사용하여 수행합니다. 모델에 따라 벡터는 수백 개에서 수천 개의차원을 가질 수 있습니다. 텍스트 분류기

DJL을 활용한 벡터 임베딩

문장과 문단을 768차원 밀집 벡터 공간으로 변환하는 paraphrase-albert-small-v2 모델 을 사용해 보겠습니다. 이 예제에서는 DJL을 사용하여 텍스트를 float[] 벡터로 변환하고, 코사인 유사도 알고리즘을 사용하여 벡터 간의 거리를 계산합니다.

DJL 종속성 추가

paraphrase-albert-small-v2 모델은 다양한 런타임(PyTorch, ONNX, TensorFlow 포함)에서 사용할 수 있습니다. DJL이 우수한 통합 기능을 제공하므로 PyTorch를 사용할 예정이지만, 다른 런타임도 유효합니다. DJL BOM과 필요한 종속성을 추가해 보겠습니다:

<dependencyManagement> 1
    <dependencies>
        <dependency>
            <groupId>ai.djl</groupId>
            <artifactId>bom</artifactId>
            <version>0.31.0</version>
            <type>pom</type>
            <scope>import</scope> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

AI 시스템 성능 엔지니어링 (Korean Edition)

AI 시스템 성능 엔지니어링 (Korean Edition)

Chris Fregly
생성형 AI를 위한 프롬프트 엔지니어링

생성형 AI를 위한 프롬프트 엔지니어링

제임스 피닉스, 마이크 테일러
AI 에이전트를 위한 메모리 관리

AI 에이전트를 위한 메모리 관리

Benjamin Labaschin, Jim Allen Wallace, Andrew Brookins, Manvinder Singh

Publisher Resources

ISBN: 0642572279882