首页 > 科技周边 > 人工智能 > 动手Grok 2模型:' Grok 2将是开源的”

动手Grok 2模型:' Grok 2将是开源的”

Lisa Kudrow
发布: 2025-03-04 09:48:11
原创
325 人浏览过

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
作者最新文章
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板