首頁 > 科技週邊 > 人工智慧 > 動手Grok 2模型:' Grok 2將是開源的”

動手Grok 2模型:' Grok 2將是開源的”

Lisa Kudrow
發布: 2025-03-04 09:48:11
原創
322 人瀏覽過

Grok是由埃隆·馬斯克(Elon Musk)創立的人工智能公司Xai開發的高級AI模型。與許多主流語言模型不同,與Chatgpt(通過OpenAi)或Claude(通過人類)相比,Grok的響應量較小,其響應更加開放。它旨在提供無偏見的,尋求真理的AI體驗,使其成為當今可用的最強大和最獨特的大語言模型(LLM)之一。借助Grok 2之類的Grok模型,您可以探索視覺功能,文本到文本等等。像其前任一樣,Grok 2也受過培訓,可以進行動態的對話,回答複雜的問題,甚至在保持邏輯和基於事實的方法的同時產生創意內容。

>目錄

    >埃隆·馬斯克(Elon Musk)的家族(Elon Musk)
  • 什麼是Grok-2?模型
  • 圖像理解:Vision Model
  • 使用langchain
  • grok 2,讓我們創建一個聊天機器人
  • 結論
  • 埃隆·馬斯克(Elon Musk)的家族
  • 這是進化:

grok-1

:該初始版本於2023年11月推出,為Grok的對話能力奠定了基礎。它被描述為“非常早期的beta產品”,培訓有限,但有可能進行快速改進。

grok-1.5動手Grok 2模型:' Grok 2將是開源的”:於2024年5月發布,此更新增強了推理功能,並將上下文長度提高到128,000個令牌,從而可以進行更複雜的交互。

>
  • grok-1.5v:在2024年4月宣布,此版本添加了處理各種視覺信息類型的功能,例如文檔和圖像。 >
  • grok-2
  • :2024年8月首次亮相,Grok-2具有升級的性能並引入了圖像生成功能,進一步擴展了其功能。 grok-2 mini
  • :也於2024年8月發布,該較小的版本旨在平衡速度和回答質量,滿足有不同需求的用戶。 >
  • grok-3 :2025年2月18日揭幕的最新迭代強調了複雜的推理和高級解決問題的能力。此版本被視為AI技術中的重大飛躍,旨在超越性能中的現有聊天機器人。
  • 現在,Grok 3在這裡! >在這裡閱讀完整的覆蓋範圍:Grok 3在這裡!它能做的會打動您的腦海! >

    什麼是grok-2?

    grok-2是Elon Musk的Xai開發的Grok Chatbot的增強版。它旨在更具用戶友好,適應能力,並精通回答問題,協助寫作和應對編碼挑戰。

    >

    關鍵功能:

    • 可訪問性 grok-2可供x(以前為Twitter)高級訂閱者。
    • >
    • 績效 xai聲稱Grok-2是比其前任Grok-1.5的“顯著進步”,具有升級的性能和推理。據報導,Grok-2的更新版本的速度更快,具有提高的精度,跟踪和多語言功能。
    • 排名
    • Grok-2在標識符“ SUS-COLUMN-R”下的LMSYS排行榜上排名第三,比人類,Gemini和Llama 3的Claude 3.5優於Claude 3.5。 圖像生成
    • grok-2具有圖像創造能力。
    • 實時數據
    • grok-2使用X帖子中的實時數據。
    • grok按鈕
    • “ grok button”可以幫助用戶發現相關上下文,了解實時事件並深入研究趨勢討論。
    • >版本xai推出了一個較小,更快的版本,稱為grok-2 mini,可以平衡響應的速度和質量。 >
    • 根據埃隆·馬斯克(Elon Musk),Grok-2將在未來幾天內開源。 關於Grok的形像生成的真相
    • >一個常見的誤解是Grok 2生成圖像,但事實並非如此。相反,xai依賴一個稱為磁通的單獨圖像模型。

    通量是最先進的AI圖像生成模型之一,尤其是在逼真的輸出時,甚至超過了Midjourney。

    用戶在X上請求圖像時,Grok充當中介,通過API調用Flux以​​生成圖像。

    >所以,雖然Grok似乎直接創建圖像,但實際上是在幕後利用磁通。

    grok的發行3:為什麼這會改變一切
    • 現在是開始使用Grok API構建AI代理的最佳時機,因為Grok 3在這裡 - 它可能是世界上最好的AI模型。
    • >
    • 注意:在一個或兩個中,您可以訪問grok 3通過API。
    • >
    為什麼Grok 3如此重要?
    • >前所未有的計算功率:>
    • 第一原理思考: Musk及其團隊從基本面優先的角度來接近AI,確保了最大的效率和表現。 高級推理
    • :Grok 3在解決創新邏輯,超過現有模型的複雜問題方面表現出色。
    • > deepSearch :啟用快速,深入的搜索,可以選擇專注於特定來源。
    • 大腦:通過分配更多的時間進行周到的分析來增強響應深度。
    • >
    • 負責的AI:X.AI的第一個經過思考模型,確保透明度和保障措施,以防止偏見和錯誤信息。 >
    • 速度和功率
    • :在巨像超級計算機上運行,​​比grok 2快三倍,非常適合實時應用。 >
    • 語音和音頻
    • :即將到來的功能包括語音模式和音頻到文本轉換。
    • >大多數人仍在使用Chatgpt或Claude,這意味著Grok仍在雷達之下。但是,如果Grok 3在接下來的幾天中證明是優越的,那麼它可能會迅速飆升,可能會在一兩年內成為世界領先的LLM。
    • 如何通過API訪問Grok模型? 到目前為止,您可以訪問兩種型號:>

    > grok-2-1212:

    >提供未經過濾的見解和原始智能的旗艦LLM。

    grok-2-Vision-1212:

    >最新的圖像知識LLM在處理多種視覺輸入(如文檔和照片)方面擅長。
      >
    • 首先,打開:https://x.ai/
    • 單擊“立即開始構建”,然後使用您的電子郵件ID登錄。 >

    根據需要添加付款方式和計費地址。

    動手Grok 2模型:' Grok 2將是開源的”

    這將為要使用的模型設置您的API鍵。

    > 動手Grok 2模型:' Grok 2將是開源的”

    >動手grok 2模型

    動手Grok 2模型:' Grok 2將是開源的”>

    >將API鍵保存在.env文件中,例如:grok_api_key =“ your_api_key”

    >

    動手Grok 2模型:' Grok 2將是開源的”>輸出

    import os
    from openai import OpenAI
    From dotenv import load_dotenv
    load_dotenv()
    GROK_API_KEY=os.getenv(“GROK_API_KEY”)
    client = OpenAI(
    api_key= GROK_API_KEY,
    base_url="https://api.x.ai/v1",
    )
    completion = client.chat.completions.create(
    model="grok-2-latest",
    messages=[
    {"role": "system", "content": "You are a Python progamminmg language expert."},
    {"role": "user", "content": "How can a beginner read and parse a JSON file in Python? You can teach them using examples"},
    ],
    )
    print(completion.choices[0].message.content)
    登入後複製
    登入後複製
    grok 2輸出的成本

    >

    >
    To help a beginner read and parse a JSON file in Python, let's go through the
     process step-by-step with examples. We'll use the `json` module, which is
     part of Python's standard library, making it easy to work with JSON data.
    
    Here's how you can read and parse a JSON file:
    
    1. First, we need to import the `json` module.
    
    2. Then, we'll open the JSON file and use `json.load()` to parse its contents.
    
    3. Finally, we can access and use the parsed data.
    
    Let's see this in action with an example:
    
    ```python
    
    # Import the json module
    
    import json
    
    # Open and read the JSON file
    
    with open('example.json', 'r') as file:
    
    # Parse the JSON data
    
    data = json.load(file)
    
    # Now we can work with the data
    
    print(data)
    
    # Accessing specific elements (assuming the JSON structure)
    
    print(data['name'])
    
    print(data['age'])
    
    # If it's a list of objects
    
    for item in data:
    
    print(f"Name: {item['name']}, Age: {item['age']}")
    
    ```
    
    Let's break down what's happening:
    
    1. We import the `json` module, which provides functions to work with JSON
     data.
    
    2. We use a `with` statement to open the file. This ensures the file is
     properly closed after we're done with it.
    
    3. We use `json.load(file)` to read and parse the JSON data from the file.
     This function automatically converts the JSON data into a Python object
    
     (usually a dictionary or a list).
    
    4. After parsing, `data` now contains the JSON content as a Python object. We
     can print it or access its elements.
    
    5. Depending on the structure of your JSON, you can access elements using
     dictionary syntax (`data['key']`) or list indexing.
    
    Here's an example of what the `example.json` file might look like:
    
    ```json
    
    {
    
    "name": "John Doe",
    
    "age": 30,
    
    "city": "New York"
    
    }
    
    ```
    
    Or, if it's a list of objects:
    
    ```json
    
    [
    
    {"name": "John Doe", "age": 30},
    
    {"name": "Jane Smith", "age": 25}
    
    ]
    
    ```
    
    For beginners, here are some important points to remember:
    
    - JSON files typically have a `.json` extension.
    
    - JSON data can be a single object (like a dictionary) or an array (like a
     list).
    
    - You need to know the structure of your JSON to access its elements
     correctly.
    
    - If you encounter errors, it's often because the JSON file is not properly
     formatted or you're trying to access elements that don't exist.
    
    To practice, beginners can create their own JSON files and try parsing them.
     They can also use online JSON validators to ensure their files are correctly
     formatted before attempting to parse them in Python.
    登入後複製
    登入後複製
    輸入成本(提示令牌)
    if completion.usage:
    print(completion.usage.to_json())
    登入後複製
    登入後複製
    登入後複製
    {<br>"completion_tokens": 713,<br>"prompt_tokens": 40,<br>"total_tokens": 753,<br>"prompt_tokens_details": {<br>"audio_tokens": 0,<br>"cached_tokens": 0,<br>"text_tokens": 40,<br>"image_tokens": 0<br>}<br>}
    登入後複製
    登入後複製
    >
    • > 40令牌×($ 2.00 / 1,000,000)
      = $ 0.00008
    • >

    >輸出成本(完成令牌)

    • 713代幣×($ 10.00 / 1,000,000)
      = $ 0.00713
    此請求的總成本

    因此,此請求的價格約為$ 0.00721(或約0.72美分)。 >

    圖像理解:視覺模型

    import os
    from openai import OpenAI
    From dotenv import load_dotenv
    load_dotenv()
    GROK_API_KEY=os.getenv(“GROK_API_KEY”)
    client = OpenAI(
    api_key= GROK_API_KEY,
    base_url="https://api.x.ai/v1",
    )
    completion = client.chat.completions.create(
    model="grok-2-latest",
    messages=[
    {"role": "system", "content": "You are a Python progamminmg language expert."},
    {"role": "user", "content": "How can a beginner read and parse a JSON file in Python? You can teach them using examples"},
    ],
    )
    print(completion.choices[0].message.content)
    登入後複製
    登入後複製

    動手Grok 2模型:' Grok 2將是開源的”

    To help a beginner read and parse a JSON file in Python, let's go through the
     process step-by-step with examples. We'll use the `json` module, which is
     part of Python's standard library, making it easy to work with JSON data.
    
    Here's how you can read and parse a JSON file:
    
    1. First, we need to import the `json` module.
    
    2. Then, we'll open the JSON file and use `json.load()` to parse its contents.
    
    3. Finally, we can access and use the parsed data.
    
    Let's see this in action with an example:
    
    ```python
    
    # Import the json module
    
    import json
    
    # Open and read the JSON file
    
    with open('example.json', 'r') as file:
    
    # Parse the JSON data
    
    data = json.load(file)
    
    # Now we can work with the data
    
    print(data)
    
    # Accessing specific elements (assuming the JSON structure)
    
    print(data['name'])
    
    print(data['age'])
    
    # If it's a list of objects
    
    for item in data:
    
    print(f"Name: {item['name']}, Age: {item['age']}")
    
    ```
    
    Let's break down what's happening:
    
    1. We import the `json` module, which provides functions to work with JSON
     data.
    
    2. We use a `with` statement to open the file. This ensures the file is
     properly closed after we're done with it.
    
    3. We use `json.load(file)` to read and parse the JSON data from the file.
     This function automatically converts the JSON data into a Python object
    
     (usually a dictionary or a list).
    
    4. After parsing, `data` now contains the JSON content as a Python object. We
     can print it or access its elements.
    
    5. Depending on the structure of your JSON, you can access elements using
     dictionary syntax (`data['key']`) or list indexing.
    
    Here's an example of what the `example.json` file might look like:
    
    ```json
    
    {
    
    "name": "John Doe",
    
    "age": 30,
    
    "city": "New York"
    
    }
    
    ```
    
    Or, if it's a list of objects:
    
    ```json
    
    [
    
    {"name": "John Doe", "age": 30},
    
    {"name": "Jane Smith", "age": 25}
    
    ]
    
    ```
    
    For beginners, here are some important points to remember:
    
    - JSON files typically have a `.json` extension.
    
    - JSON data can be a single object (like a dictionary) or an array (like a
     list).
    
    - You need to know the structure of your JSON to access its elements
     correctly.
    
    - If you encounter errors, it's often because the JSON file is not properly
     formatted or you're trying to access elements that don't exist.
    
    To practice, beginners can create their own JSON files and try parsing them.
     They can also use online JSON validators to ensure their files are correctly
     formatted before attempting to parse them in Python.
    登入後複製
    登入後複製

    >輸入圖像

    動手Grok 2模型:' Grok 2將是開源的”

    >輸出

    if completion.usage:
    print(completion.usage.to_json())
    登入後複製
    登入後複製
    登入後複製
    {<br>"completion_tokens": 713,<br>"prompt_tokens": 40,<br>"total_tokens": 753,<br>"prompt_tokens_details": {<br>"audio_tokens": 0,<br>"cached_tokens": 0,<br>"text_tokens": 40,<br>"image_tokens": 0<br>}<br>}
    登入後複製
    登入後複製
    import os
    from openai import OpenAI
    from getpass import getpass
    XAI_KEY = getpass('Enter Grok API Key: ')
    登入後複製

    動手Grok 2模型:' Grok 2將是開源的”

    grok 2輸出的成本

    >

    >

    輸入成本(提示令牌)>

      >文本輸入成本:
      • 52代幣×($ 2.00 / 1,000,000)= $ 0.000104
      • >
    • 圖像輸入成本:
      • 768代幣×($ 2.00 / 1,000,000)= $ 0.001536
      • >
    • >總輸入成本= $ 0.00164

    >輸出成本(完成令牌)>

      >文本輸出成本:
      • > 483代幣×($ 10.00 / 1,000,000)= $ 0.00483
      • >
    • 此請求的總成本

    因此,此請求的價格約為0.00647美元(或約0.65美分)。 > 使用langchain

    grok 2

    >輸出
    os.environ['XAI_API_KEY'] = XAI_KEY
    image_url = (
    "https://safarisafricana.com/wp-content/uploads/2020/05/Copy-of-SAFAF-2X1-images-60.jpg"
    )
    client = OpenAI(
    api_key=XAI_KEY,
    base_url="https://api.x.ai/v1",
    )
    messages = [
    {
    "role": "user",
    "content": [
    {
    "type": "image_url",
    "image_url": {
    "url": image_url,
    "detail": "high",
    },
    },
    {
    "type": "text",
    "text": """Please provide a detailed description of the contents in this image, including any notable objects, colors, patterns, and the overall scene.
    If there are any texts or symbols, please transcribe or interpret them as well.""",
    },
    ],
    },
    ]
    completion = client.chat.completions.create(
    model="grok-2-vision-latest",
    messages=messages,
    temperature=0.01,
    )
    print(completion.choices[0].message.content)
    登入後複製

    讓我們創建一個聊天機器人
    The image depicts a vibrant and lush savanna scene, showcasing a variety of<br> wildlife in their natural habitat. Here is a detailed description:<br><br>### Animals:<br><br>1. **Giraffes**: There are three giraffes in the image, standing tall with<br> their long necks and distinctive spotted patterns. Their colors are<br> primarily light brown with orange-brown patches. They are positioned towards<br> the center and right side of the image.<br><br>2. **Zebras**: Several zebras are present, identifiable by their black and <br>white striped patterns. They are scattered across the scene, with some<br> standing and others grazing. Their stripes create a striking contrast <br>against the green grass.<br><br>3. **Antelopes/Deer**: There are multiple antelopes or deer-like animals,<br> with slender bodies and light brown coats. Some have white underbellies and<br> legs. They are smaller in size compared to the giraffes and zebras, and are<br> seen grazing or standing around.<br><br>### Vegetation:<br><br>- **Grass**: The ground is covered with lush green grass, indicating a<br> healthy and vibrant ecosystem.<br><br>- **Bushes and Trees**: There are various green bushes and small trees<br> scattered throughout the scene. In the background, there are larger trees,<br> including one with a broad canopy on the left side of the image.<br><br>### Colors:<br><br>- **Green**: Dominant color due to the grass, bushes, and trees.<br><br>- **Brown**: Seen in the giraffes' patches, antelopes' coats, and some parts<br> of the zebras.<br><br>- **Black and White**: The zebras' stripes.<br><br>- **Orange**: Subtle tones in the giraffes' patches.<br><br>### Patterns:<br><br>- **Giraffe Spots**: Irregular, orange-brown patches on a light brown<br> background.<br><br>- **Zebra Stripes**: Bold, black and white stripes with varying thickness.<br><br>- **Antelope/Deer**: Light brown with white underbellies and legs.<br><br>### Overall Scene:<br><br>The scene is set in a savanna or grassland environment, typical of African<br> landscapes. The animals are coexisting peacefully, suggesting a harmonious<br> ecosystem. The lighting suggests it might be daytime, with natural sunlight<br> illuminating the scene, enhancing the vividness of the colors.<br><br>### Texts or Symbols:<br><br>There are no visible texts or symbols in the image.<br><br>This image captures the essence of wildlife in a natural setting,<br> highlighting the diversity and beauty of the animals and their environment.
    登入後複製

    >輸出
    if completion.usage:
    print(completion.usage.to_json())
    登入後複製
    登入後複製
    登入後複製

    結論
    {<br>"completion_tokens": 483,<br>"prompt_tokens": 820,<br>"total_tokens": 1303,<br>"prompt_tokens_details": {<br>"audio_tokens": 0,<br>"cached_tokens": 0,<br>"text_tokens": 52,<br>"image_tokens": 768<br>}<br>}
    登入後複製
    隨著Grok 3的發布即將來臨,Xai迅速將自己定位為Openai,Google DeepMind和Anthropic的認真挑戰者。如果Xai的龐大計算能力轉化為優越的AI模型,則Grok可以在未來幾年內主導AI空間。對於開發人員,企業家和人工智能愛好者而言,現在是時候開始使用Grok建造了。早期採用者將獲得可能是最大的AI革命的主要優勢。

    >

    >體驗Xai Grok 3的力量,地球上最聰明的AI!參加我們的課程,以探索其開創性的功能並立即改變您的項目! 我希望您能找到有關Grok 2動手提供信息的文章。讓我在下面的評論部分中知道您的想法。

以上是動手Grok 2模型:' Grok 2將是開源的”的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板