Internlm Xcomposer2d5 7b Chat
模型概述
這是一個多模態對話大模型,支持視覺問答和開放式對話,能夠理解和分析圖像、視頻內容,並進行自然語言交互。
模型特點
多模態理解能力
能夠同時處理和理解圖像、視頻和文本信息
視頻內容分析
可以分析視頻幀內容,理解視頻中的動作和場景
高分辨率圖像解析
能夠解析高分辨率圖像中的細節信息
多輪對話能力
支持基於歷史對話的上下文理解
模型能力
視頻內容理解
圖像分析
多輪對話
多模態指令跟隨
開放式問答
使用案例
內容分析
體育視頻分析
分析體育比賽視頻內容,識別運動員動作和比賽結果
能準確識別運動員編號、比賽結果等關鍵信息
車輛分析
比較不同車輛的優劣勢
能詳細分析多款車型的特點和適用場景
信息提取
信息圖解析
從複雜信息圖中提取結構化數據
能準確提取信息圖中的關鍵數據和事實
🚀 InternLM-XComposer-2.5-Chat
InternLM-XComposer-2.5-Chat 是基於 internlm/internlm-xcomposer2d5-7b 訓練的聊天模型,具備更出色的多模態指令遵循和開放式對話能力。
InternLM-XComposer-2.5-Chat
[💻GitHub 倉庫](https://github.com/InternLM/InternLM-XComposer)
[論文](https://huggingface.co/papers/2501.12368)
🚀 快速開始
我們提供一個簡單的示例,展示如何使用 🤗 Transformers 來使用 InternLM-XComposer2.5。
視頻理解
import torch
from transformers import AutoModel, AutoTokenizer
torch.set_grad_enabled(False)
# init model and tokenizer
model = AutoModel.from_pretrained('internlm/internlm-xcomposer2d5-7b-chat', torch_dtype=torch.bfloat16, trust_remote_code=True).cuda().eval()
tokenizer = AutoTokenizer.from_pretrained('internlm/internlm-xcomposer2d5-7b-chat', trust_remote_code=True)
model.tokenizer = tokenizer
query = 'Here are some frames of a video. Describe this video in detail'
image = ['./examples/liuxiang.mp4',]
with torch.autocast(device_type='cuda', dtype=torch.float16):
response, his = model.chat(tokenizer, query, image, do_sample=False, num_beams=3, use_meta=True)
print(response)
# The video begins with a man in a red and yellow uniform standing on the starting line of a track, preparing to compete in the 110-meter hurdles at the Athens 2004 Olympic Games. He is identified as Liu Xiang, a Chinese athlete, and his bib number is 1363. The scene is set in a stadium filled with spectators, indicating the significance of the event.
# As the race begins, all the athletes start running, but Liu Xiang quickly takes the lead. However, he encounters a hurdle and knocks it over. Despite this setback, he quickly recovers and continues to run. The race is intense, with athletes from various countries competing fiercely. In the end, Liu Xiang emerges as the winner with a time of 12.91 seconds, securing the gold medal for China.
# The video then transitions to a slow-motion replay of the race, focusing on Liu Xiang's performance and the knockdown of the hurdle. This allows viewers to appreciate the skill and determination of the athlete.
# Following the race, Liu Xiang is seen lying on the track, possibly exhausted from the intense competition. He then stands up and begins to celebrate his victory, waving his arms in the air and running around the track. The crowd cheers and celebrates with him, creating a joyful atmosphere.
# The video concludes with a replay of Liu Xiang's gold medal-winning moment, emphasizing the significance of his achievement at the Athens 2004 Olympic Games.
# Throughout the video, the Olympic logo is prominently displayed, reminding viewers of the global significance of the event and the athletes' dedication and perseverance in their pursuit of victory.
query = 'tell me the athlete code of Liu Xiang'
image = ['./examples/liuxiang.mp4',]
with torch.autocast(device_type='cuda', dtype=torch.float16):
response, _ = model.chat(tokenizer, query, image, history=his, do_sample=False, num_beams=3, use_meta=True)
print(response)
# The athlete code of Liu Xiang is 1363.
多圖像多輪對話
import torch
from transformers import AutoModel, AutoTokenizer
torch.set_grad_enabled(False)
# init model and tokenizer
model = AutoModel.from_pretrained('internlm/internlm-xcomposer2d5-7b-chat', torch_dtype=torch.bfloat16, trust_remote_code=True).cuda().eval()
tokenizer = AutoTokenizer.from_pretrained('internlm/internlm-xcomposer2d5-7b-chat', trust_remote_code=True)
model.tokenizer = tokenizer
query = 'Image1 <ImageHere>; Image2 <ImageHere>; Image3 <ImageHere>; I want to buy a car from the three given cars, analyze their advantages and weaknesses one by one'
image = ['./examples/cars1.jpg',
'./examples/cars2.jpg',
'./examples/cars3.jpg',]
with torch.autocast(device_type='cuda', dtype=torch.float16):
response, his = model.chat(tokenizer, query, image, do_sample=False, num_beams=3, use_meta=True)
print(response)
# Certainly! Let's analyze the advantages and disadvantages of each car:
#
# 1. **Mercedes-Benz G-Class (SUV)**:
# - **Advantages**:
# - **Off-Road Capability**: The G-Class is renowned for its off-road prowess. It can handle a variety of terrains, making it ideal for adventurous driving.
# - **Reliability**: Mercedes-Benz is known for producing reliable vehicles, and the G-Class is no exception. It has a reputation for durability and longevity.
# - **Luxury Features**: As a Mercedes-Benz, the G-Class comes with a host of luxury features, including high-quality materials and advanced technology.
# - **Disadvantages**:
# - **Fuel Efficiency**: The G-Class is not known for its fuel efficiency. It consumes a significant amount of gasoline, which can be a disadvantage for those concerned with fuel economy.
# - **Size and Weight**: The G-Class is large and heavy, which can affect its handling and maneuverability, especially in urban environments.
# - **Cost**: The G-Class is generally more expensive compared to other SUVs, which can be a deterrent for some buyers.
#
# 2. **Bugatti Chiron (Sports Car)**:
# - **Advantages**:
# - **Performance**: The Bugatti Chiron is one of the fastest production cars available. It boasts impressive acceleration and top speed, making it a thrilling driving experience.
# - **Design**: The Chiron has a sleek and futuristic design that is both aesthetically pleasing and aerodynamically efficient.
# - **Status Symbol**: Owning a Bugatti is often seen as a status symbol, attracting attention and admiration.
# - **Disadvantages**:
# - **Cost**: The Bugatti Chiron is one of the most expensive cars in the world, making it out of reach for many potential buyers.
# - **Maintenance**: Bugatti vehicles require specialized maintenance, which can be costly and difficult to find.
# - **Road Legality**: In some regions, the Chiron may not be road-legal due to its high top speed and powerful engine.
#
# 3. **BMW i Vision Dynamics (Electric Concept Car)**:
# - **Advantages**:
# - **Environmental Impact**: As an electric vehicle, the i Vision Dynamics has a lower environmental impact compared to traditional gasoline-powered cars.
# - **Design**: The i Vision Dynamics has a unique and futuristic design that sets it apart from conventional cars.
# - **Performance**: Despite being an electric vehicle, the i Vision Dynamics boasts impressive performance, including a top speed of over 300 km/h.
# - **Disadvantages**:
# - **Cost**: Like the Bugatti Chiron, the i Vision Dynamics is an expensive concept car, making it inaccessible to most buyers.
# - **Range**: Electric vehicles typically have a limited range compared to gasoline-powered cars, which can be a concern for long-distance travel.
# - **Infrastructure**: The availability of charging stations can vary widely by region, which can limit the practicality of owning an electric car.
# In summary, the Mercedes-Benz G-Class is a reliable and capable off-road vehicle with luxury features, but it may not be the most fuel-efficient or affordable option. The Bugatti Chiron offers unparalleled performance and status, but it is extremely expensive and requires specialized maintenance. The BMW i Vision Dynamics is an innovative and environmentally friendly concept car with impressive performance, but it is also costly and limited by range and charging infrastructure. Each car has its own unique set of advantages and disadvantages, and the choice ultimately depends on individual preferences and priorities.
query = 'Image4 <ImageHere>; How about the car in Image4'
image.append('./examples/cars4.jpg')
with torch.autocast(device_type='cuda', dtype=torch.float16):
response, _ = model.chat(tokenizer, query, image, do_sample=False, num_beams=3, history= his, use_meta=True)
print(response)
# The car in Image4 is a **Ferrari LaFerrari**. The LaFerrari is a hybrid supercar produced by Ferrari, combining a V12 engine with an electric motor. Here's a detailed analysis of its advantages and disadvantages:
#
# ### **Advantages:**
# 1. **Performance**: The LaFerrari is one of the fastest production cars available, with a top speed of over 217 mph (349 km/h). It boasts impressive acceleration and handling, making it a thrilling driving experience.
# 2. **Design**: The LaFerrari has a distinctive and aggressive design that sets it apart from other supercars. Its aerodynamic features and sleek lines contribute to its performance and visual appeal.
# 3. **Hybrid Technology**: The LaFerrari uses a hybrid powertrain, combining a 6.3-liter V12 engine with an electric motor. This hybrid system provides a balance of power and efficiency, reducing emissions compared to traditional gasoline engines.
# 4. **Status Symbol**: Owning a LaFerrari is often seen as a status symbol, attracting attention and admiration. It represents a pinnacle of automotive engineering and luxury.
# 5. **Reliability**: Ferrari is known for producing high-quality, reliable vehicles. The LaFerrari benefits from the brand's reputation for excellence in engineering and craftsmanship.
### **Disadvantages:**
# 1. **Cost**: The LaFerrari is one of the most expensive cars in the world, making it inaccessible to most potential buyers. Its high price can be a significant deterrent.
# 2. **Maintenance**: Ferrari vehicles require specialized maintenance, which can be costly and difficult to find. The hybrid system may also add to the complexity and expense of servicing the car.
# 3. **Road Legality**: In some regions, the LaFerrari may not be road-legal due to its high top speed and powerful engine. This can limit its usability and appeal.
# 4. **Fuel Efficiency**: Despite the hybrid system, the LaFerrari consumes a significant amount of fuel, which can be a disadvantage for those concerned with fuel economy.
# 5. **Size and Weight**: The LaFerrari is a large and heavy vehicle, which can affect its handling and maneuverability, especially in urban environments.
# In summary, the Ferrari LaFerrari is a high-performance hybrid supercar with a distinctive design and impressive capabilities. However, its high cost, specialized maintenance requirements, and limited road legality can be significant disadvantages for some buyers. The LaFerrari is best suited for those who prioritize performance, luxury, and status over practicality and affordability.
高分辨率圖像理解
import torch
from transformers import AutoModel, AutoTokenizer
torch.set_grad_enabled(False)
# init model and tokenizer
model = AutoModel.from_pretrained('internlm/internlm-xcomposer2d5-7b-chat', torch_dtype=torch.bfloat16, trust_remote_code=True).cuda().eval()
tokenizer = AutoTokenizer.from_pretrained('internlm/internlm-xcomposer2d5-7b-chat', trust_remote_code=True)
model.tokenizer = tokenizer
query = 'Analyze the given image in a detail manner'
image = ['./examples/dubai.png']
with torch.autocast(device_type='cuda', dtype=torch.float16):
response, _ = model.chat(tokenizer, query, image, do_sample=False, num_beams=3, use_meta=True)
print(response)
# The image is an infographic titled "Amazing Facts About Dubai." Here's a detailed analysis of its content:
#
# 1. **Title and Introduction:**
# - The title is prominently displayed at the top of the image in bold, blue letters.
# - The image features a colorful skyline of Dubai, highlighting the city's modern architecture.
#
# 2. **Facts About Palm Jumeirah:**
# - Palm Jumeirah is the largest artificial island and is visible from space.
# - In 1968, there were only 1.5 million cars in Dubai.
#
# 3. **Dubai's Gold Chain:**
# - Dubai has the world's largest Gold Chain, which is 4.2 km long.
# - 7 out of the 10 tallest hotels in the world are located in Dubai.
#
# 4. **Crime Rate and Income Tax:**
# - The crime rate is near 0%.
# - The income tax rate is 0%.
#
# 5. **Dubai Mall:**
# - Dubai Mall is the largest shopping mall in the world with 1200 stores.
# - 17% of the population is Emirati, and 83% are immigrants.
#
# 6. **Dubai's Address System:**
# - Dubai has no standard address system, with no zip codes, area codes, or postal services.
#
# 7. **Dispense Gold:**
# - Dubai is building a climate-controlled City, 2.25 times as big as Monaco.
# - The Royal Suite at Burj Al Arab is $24,000 per night.
#
# 8. **License and Billionaires:**
# - You need a license to drink alcohol even at home.
# - The net worth of the four listed billionaires is roughly equal to the GDP of Honduras.
#
# 9. **Sources:**
# - The infographic cites sources from Wikipedia, Forbes, Gulf News, and The Guardian.
#
# 10. **Design and Compilation:**
# - The image is designed and compiled by FMEXtensions, a company based in the United Arab Emirates.
#
# The infographic uses a combination of text, icons, and images to convey interesting facts about Dubai, emphasizing its modernity, wealth, and unique features.
📦 安裝指南
使用 Transformers 加載模型
要使用 Transformers 加載 InternLM-XComposer2-2d5-Chat 模型,請使用以下代碼:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
ckpt_path = "internlm/internlm-xcomposer2d5-7b-chat"
tokenizer = AutoTokenizer.from_pretrained(ckpt_path, trust_remote_code=True).cuda()
# Set `torch_dtype=torch.floatb16` to load model in bfloat16, otherwise it will be loaded as float32 and might cause OOM Error.
model = AutoModelForCausalLM.from_pretrained(ckpt_path, torch_dtype=torch.bfloat16, trust_remote_code=True).cuda()
model = model.eval()
📄 許可證
代碼採用 Apache-2.0 許可證,而模型權重完全開放用於學術研究,也允許免費商業使用。如需申請商業許可證,請填寫申請表(英文)/申請表(中文)。如有其他問題或合作需求,請聯繫 internlm@pjlab.org.cn。
Clip Vit Large Patch14 336
基於Vision Transformer架構的大規模視覺語言預訓練模型,支持圖像與文本的跨模態理解
文本生成圖像
Transformers

C
openai
5.9M
241
Fashion Clip
MIT
FashionCLIP是基於CLIP開發的視覺語言模型,專門針對時尚領域進行微調,能夠生成通用產品表徵。
文本生成圖像
Transformers 英語

F
patrickjohncyh
3.8M
222
Gemma 3 1b It
Gemma 3是Google推出的輕量級先進開放模型系列,基於與Gemini模型相同的研究和技術構建。該模型是多模態模型,能夠處理文本和圖像輸入並生成文本輸出。
文本生成圖像
Transformers

G
google
2.1M
347
Blip Vqa Base
Bsd-3-clause
BLIP是一個統一的視覺語言預訓練框架,擅長視覺問答任務,通過語言-圖像聯合訓練實現多模態理解與生成能力
文本生成圖像
Transformers

B
Salesforce
1.9M
154
CLIP ViT H 14 Laion2b S32b B79k
MIT
基於OpenCLIP框架在LAION-2B英文數據集上訓練的視覺-語言模型,支持零樣本圖像分類和跨模態檢索任務
文本生成圖像
Safetensors
C
laion
1.8M
368
CLIP ViT B 32 Laion2b S34b B79k
MIT
基於OpenCLIP框架在LAION-2B英語子集上訓練的視覺-語言模型,支持零樣本圖像分類和跨模態檢索
文本生成圖像
Safetensors
C
laion
1.1M
112
Pickscore V1
PickScore v1 是一個針對文本生成圖像的評分函數,可用於預測人類偏好、評估模型性能和圖像排序等任務。
文本生成圖像
Transformers

P
yuvalkirstain
1.1M
44
Owlv2 Base Patch16 Ensemble
Apache-2.0
OWLv2是一種零樣本文本條件目標檢測模型,可通過文本查詢在圖像中定位對象。
文本生成圖像
Transformers

O
google
932.80k
99
Llama 3.2 11B Vision Instruct
Llama 3.2 是 Meta 發佈的多語言多模態大型語言模型,支持圖像文本到文本的轉換任務,具備強大的跨模態理解能力。
文本生成圖像
Transformers 支持多種語言

L
meta-llama
784.19k
1,424
Owlvit Base Patch32
Apache-2.0
OWL-ViT是一個零樣本文本條件目標檢測模型,可以通過文本查詢搜索圖像中的對象,無需特定類別的訓練數據。
文本生成圖像
Transformers

O
google
764.95k
129
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98