오늘날의 빠르게 진행되는 비즈니스 환경에서 조직에는 의사 결정을 주도하고 운영을 최적화하며 경쟁력을 유지하는 데이터가 침수됩니다. 그러나이 데이터에서 실행 가능한 통찰력을 추출하는 것은 여전히 큰 장애물입니다. 에이전트 AI와 통합 될 때 RAG (Recreved-Augmented Generation) 시스템은 관련 정보를 검색 할뿐만 아니라 컨텍스트 인식 통찰력을 실시간으로 처리하고 전달 함으로써이 과제를 해결합니다. 이 조합은 비즈니스가 데이터 세트를 자율적으로 쿼리하고 제품 기능, 통합 및 운영에 대한 통찰력을 추출하는 지능형 에이전트를 만들 수 있습니다.
학습 목표
이 JSON 파일에는 긁힌 각 페이지의 URL, 제목 및 내용이 포함되어 있습니다. 이 구조화 된 데이터는 이제 RAG 시스템의 임베딩 생성 및 질문 응답과 같은 추가 처리에 사용될 수 있습니다. 아래는 원본 코드의 출력 스크린 샷입니다. 무결성을 유지하기 위해 민감한 정보가 가려졌습니다
코드 스 니펫 :
2 단계 : 원시 텍스트 컨텐츠 추출
3 단계 : 처리를 위해 AI 에이전트에 데이터를 전송합니다
사용할 모델을 지정합니다. 이 경우 텍스트 데이터를 처리하고 응답을 생성 할 수 있도록 언어 모델이 선택됩니다.
생성 된 응답의 최대 길이를 설정합니다
top_p :
일단 AI 모델이 컨텐츠를 처리하면 구조화 된 정보의 덩어리를 반환합니다. 우리는이 청크를 수집하고 연락하여 전체 결과 세트를 생성하여 데이터가 손실되지 않고 최종 출력이 완료되도록합니다. 코드 스 니펫 : 변수로 내용을 연결하여 전체적이고 구조화 된 통찰력 세트를 초래합니다. 이해 관계자가 추가 분석을 위해 쉽게 소비하거나 사용할 수있는 형식으로 이러한 통찰력을 추출합니다. 아래는 원래 코드의 출력 스크린 샷이며, 무결성을 유지하기 위해 민감한 정보가 마스크되었습니다.
5 단계 : 오류 처리 및 데이터 무결성 유지
처리하는 동안 불완전한 컨텐츠 또는 네트워크 문제와 같은 오류가 발생할 가능성이 항상 있습니다. 오류 처리 메커니즘을 사용하여 모든 유효한 항목에 대해 프로세스가 원활하게 계속되도록합니다.
코드 스 니펫 :
출력
위의 코드를 실행 한 후 처리 된 JSON 파일에는 각 항목에 대한 추출 된 포인트가 포함됩니다. Fields PM_Points는 제품 기능, 통합, 문제 해결 단계 등과 관련된 구조화 된 정보를 보유합니다.
검색을 위해 섭취 한 생성 파이프 라인 구현
마지막으로, RAG를 활용하면 방대한 데이터 세트에서 상황 정보를 검색하고 합성하여 복잡한 쿼리에 동적으로 응답 할 수 있습니다. 이러한 구성 요소는 함께 회사에 대한 실행 가능한 통찰력을 수집, 처리 및 제공 할 수있는 에이전트 플랫폼을 구축하는 데 사용할 수있는 포괄적 인 설정을 형성합니다. 이 프레임 워크는 고급 인텔리전스 시스템을 개발하기위한 토대 역할을 할 수 있으며, 조직이 경쟁 분석을 자동화하고 시장 동향을 모니터링하며 해당 산업에 대한 정보를 유지할 수 있도록 할 수 있습니다.
결론
오늘날의 데이터 중심 세계에서 구조화되지 않은 회사 데이터에서 실행 가능한 통찰력을 추출하는 것이 중요합니다. RAG (Resprieved-Augmented Generation) 시스템은 데이터 스크래핑, 포인터 추출 및 지능형 쿼리를 결합하여 회사 인텔리전스를위한 강력한 플랫폼을 만듭니다. Rag Systems는 주요 정보를 구성하고 실시간, 상황 별 응답을 가능하게함으로써 조직에서 현명한 의사 결정을 강화하고 비즈니스가 데이터를 지원하고 적응 가능한 의사 결정을 내릴 수 있도록 도와줍니다.
이 기사는 데이터 과학 블로그 톤의
BFS를 사용한 데이터 추출 및 데이터를 긁어 내고 AI 에이전트
로 정보 추출을 긁어내는 데이터 추출 검색 대기 생성 파이프 라인 구현
링크 추출을 수행하는 코드는 다음과 같습니다
출력
import requests
from bs4 import BeautifulSoup
from collections import deque
# Function to extract links using BFS
def bfs_link_extraction(start_url, max_depth=3):
visited = set() # To track visited links
queue = deque([(start_url, 0)]) # Queue to store URLs and current depth
all_links = []
while queue:
url, depth = queue.popleft()
if depth > max_depth:
continue
# Fetch the content of the URL
try:
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
# Extract all links in the page
links = soup.find_all('a', href=True)
for link in links:
full_url = link['href']
if full_url.startswith('http') and full_url not in visited:
visited.add(full_url)
queue.append((full_url, depth + 1))
all_links.append(full_url)
except requests.exceptions.RequestException as e:
print(f"Error fetching {url}: {e}")
return all_links
# Start the BFS from the homepage
start_url = 'https://www.example.com' # Replace with the actual homepage URL
all_extracted_links = bfs_link_extraction(start_url)
print(f"Extracted {len(all_extracted_links)} links.")
import requests
from bs4 import BeautifulSoup
from collections import deque
# Function to extract links using BFS
def bfs_link_extraction(start_url, max_depth=3):
visited = set() # To track visited links
queue = deque([(start_url, 0)]) # Queue to store URLs and current depth
all_links = []
while queue:
url, depth = queue.popleft()
if depth > max_depth:
continue
# Fetch the content of the URL
try:
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
# Extract all links in the page
links = soup.find_all('a', href=True)
for link in links:
full_url = link['href']
if full_url.startswith('http') and full_url not in visited:
visited.add(full_url)
queue.append((full_url, depth + 1))
all_links.append(full_url)
except requests.exceptions.RequestException as e:
print(f"Error fetching {url}: {e}")
return all_links
# Start the BFS from the homepage
start_url = 'https://www.example.com' # Replace with the actual homepage URL
all_extracted_links = bfs_link_extraction(start_url)
print(f"Extracted {len(all_extracted_links)} links.")
코드 스 니펫 :
이 시점에서 input_text 변수에는 추가 처리를 위해 AI 모델로 보낼 원시 텍스트 컨텐츠가 포함되어 있습니다. 각 항목을 처리하기 전에 필요한 키의 존재를 보장하는 것이 중요합니다. 여기서, 코드는 GROQ에 API 호출을 시작하여 input_text를 보내고 메시지 페이로드의 일부로 지침을 보냅니다. 시스템 메시지는 정확한 작업에 대한 AI 모델을 지시하고 사용자 메시지는 처리 할 컨텐츠를 제공합니다. 우리는 온도, max_tokens 및 top_p 매개 변수를 사용하여 생성 된 출력의 무작위성과 길이를 제어합니다.
API 호출 구성 : <b>
</b>
Extracted 1500 links.
는 응답의 창의성을 제어합니다. 가치가 높을수록 더 창의적 인 반응을 가져 오는 반면, 더 낮은 값은 더 결정 론적으로 만듭니다. import json
# Function to scrape and extract data from the URLs
def scrape_data_from_links(links):
scraped_data = []
for link in links:
try:
response = requests.get(link)
soup = BeautifulSoup(response.content, 'html.parser')
# Example: Extract 'title' and 'content' (modify according to your needs)
title = soup.find('title').get_text()
content = soup.find('div', class_='content').get_text() # Adjust selector
# Store the extracted data
scraped_data.append({
'url': link,
'title': title,
'content': content
})
except requests.exceptions.RequestException as e:
print(f"Error scraping {link}: {e}")
return scraped_data
# Scrape data from the extracted links
scraped_contents = scrape_data_from_links(all_extracted_links)
# Save scraped data to a JSON file
with open('/content/scraped_data.json', 'w') as outfile:
json.dump(scraped_contents, outfile, indent=4)
print("Data scraping complete.")
import requests
from bs4 import BeautifulSoup
from collections import deque
# Function to extract links using BFS
def bfs_link_extraction(start_url, max_depth=3):
visited = set() # To track visited links
queue = deque([(start_url, 0)]) # Queue to store URLs and current depth
all_links = []
while queue:
url, depth = queue.popleft()
if depth > max_depth:
continue
# Fetch the content of the URL
try:
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
# Extract all links in the page
links = soup.find_all('a', href=True)
for link in links:
full_url = link['href']
if full_url.startswith('http') and full_url not in visited:
visited.add(full_url)
queue.append((full_url, depth + 1))
all_links.append(full_url)
except requests.exceptions.RequestException as e:
print(f"Error fetching {url}: {e}")
return all_links
# Start the BFS from the homepage
start_url = 'https://www.example.com' # Replace with the actual homepage URL
all_extracted_links = bfs_link_extraction(start_url)
print(f"Extracted {len(all_extracted_links)} links.")
코드 스 니펫 :
이 코드는 처리 된 데이터를 효율적으로 저장하고 나중에 쉽게 액세스 할 수 있습니다. 각 항목을 각각의 구조화 된 지점으로 저장하여 추출 된 정보를 검색하고 분석합니다.
이 패키지는 Langchain 내의 문서 처리, 벡터화 및 OpenAI 모델을 통합하는 데 중요합니다. JQ는 경량 JSON 프로세서이며 Langchain은 언어 모델 파이프 라인을 구축하는 핵심 프레임 워크 역할을합니다. Langchain-Openai는 GPT와 같은 OpenAI 모델의 통합을 용이하게하며 Langchain-Chroma는 문서 임베딩을 관리하기위한 크로마 기반 벡터 스토어를 제공합니다.
이 단계에서는 이전에 추출 된 데이터 (아마도 제품 기능, 통합 및 기능 포함)가 추가 처리를 위해로드되었습니다.
3 단계 : 문서를 작은 덩어리로 분할
import requests
from bs4 import BeautifulSoup
from collections import deque
# Function to extract links using BFS
def bfs_link_extraction(start_url, max_depth=3):
visited = set() # To track visited links
queue = deque([(start_url, 0)]) # Queue to store URLs and current depth
all_links = []
while queue:
url, depth = queue.popleft()
if depth > max_depth:
continue
# Fetch the content of the URL
try:
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
# Extract all links in the page
links = soup.find_all('a', href=True)
for link in links:
full_url = link['href']
if full_url.startswith('http') and full_url not in visited:
visited.add(full_url)
queue.append((full_url, depth + 1))
all_links.append(full_url)
except requests.exceptions.RequestException as e:
print(f"Error fetching {url}: {e}")
return all_links
# Start the BFS from the homepage
start_url = 'https://www.example.com' # Replace with the actual homepage URL
all_extracted_links = bfs_link_extraction(start_url)
print(f"Extracted {len(all_extracted_links)} links.")
import requests
from bs4 import BeautifulSoup
from collections import deque
# Function to extract links using BFS
def bfs_link_extraction(start_url, max_depth=3):
visited = set() # To track visited links
queue = deque([(start_url, 0)]) # Queue to store URLs and current depth
all_links = []
while queue:
url, depth = queue.popleft()
if depth > max_depth:
continue
# Fetch the content of the URL
try:
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
# Extract all links in the page
links = soup.find_all('a', href=True)
for link in links:
full_url = link['href']
if full_url.startswith('http') and full_url not in visited:
visited.add(full_url)
queue.append((full_url, depth + 1))
all_links.append(full_url)
except requests.exceptions.RequestException as e:
print(f"Error fetching {url}: {e}")
return all_links
# Start the BFS from the homepage
start_url = 'https://www.example.com' # Replace with the actual homepage URL
all_extracted_links = bfs_link_extraction(start_url)
print(f"Extracted {len(all_extracted_links)} links.")
Extracted 1500 links.
보너스 : 여기에서 논의 된 모든 코드는 다음 링크에서 제공됩니다. 각 노트북에 대한 자체 설명 이름이있는 총 4 개의 노트북을 사용할 수 있습니다. 기업을 탐색, 개발 및 혁명을 자유롭게하십시오!
위 내용은 조직에서 현명한 의사 결정을위한 헝겊 시스템 구축의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!