微信扫码
与创始人交个朋友
轻量级大语言模型模型可以让前沿的 AI 技术更加易于获取、高效、低成本。它们支持各种应用。
Gemma 2性能
在Gemma 2的训练过程中,采用了严格的安全协议。这包括过滤预训练数据,并在各种指标上进行全面测试,以检测和解决潜在的偏见和风险。
图:评估Gemma 2的9B和27B指令
在我们开始之前,让我们收集一些关于GPU配置的信息。
nvidia-smi
ollama run gemma2
视频:运行于 Ppaperspace 的 Gemma 2模型给出的答案
我们还给了它一个编程问题:编写一个函数,通过填充空白单元格来解决数独谜题。数独谜题是一个9x9的网格,目标是填充网格,使得每一行、每一列和每个3x3的子网格都恰好包含数字1到9一次。空白单元格由字符表示。
它给出的输出是这样的:
def solveSudoku(puzzle):
"""
Solves a Sudoku puzzle.
Args:
puzzle (list): A list of strings representing the Sudoku puzzle.
Returns:
list: A list of strings representing the solved Sudoku puzzle.
"""
# Iterate over the rows, columns, and subgrids.
for row in range(9):
for col in range(9):
if puzzle[row][col] == '.':
# Check if the number is already in the row, column, or subgrid.
for i in range(9):
if puzzle[row][i] != '.' and puzzle[i][col] != '.' and puzzle[row][col] == puzzle[i][col]:
continue
# Find the possible numbers for the cell.
possible_numbers = set()
for i in range(1, 10):
if not is_valid(puzzle, row, col, i):
possible_numbers.add(i)
# Try each possible number.
for number in possible_numbers:
puzzle[row][col] = str(number)
if solveSudoku(puzzle):
return puzzle
puzzle[row][col] = '.'
# If no solution is found, return the original puzzle.
return puzzle
# Helper function to check if a number is valid for a cell.
def is_valid(puzzle, row, col, number):
for i in range(9):
if puzzle[row][i] == str(number) or puzzle[i][col] == str(number):
return False
for i in range(3):
for j in range(3):
if puzzle[row // 3 * 3 + i][col // 3 * 3 + j] == str(number):
return False
return True
```
**Explanation:**
* The `solveSudoku` function iterates over the rows, columns, and subgrids of the Sudoku puzzle.
* For each empty cell, it checks if the number is already in the row, column, or subgrid.
* It then finds the possible numbers for the cell and tries each one.
* If a solution is found, it returns the solved puzzle. Otherwise, it returns the original puzzle.
* The `is_valid` function checks if a number is valid for a cell by ensuring that it is not already in the row, column, or subgrid.
**Example Usage:**
```python
# Example Sudoku puzzle.
puzzle = [
['5', '3', '.', '.', '7', '8', '.', '.', '.'],
['.', '7', '4', '6', '.', '5', '8', '9', '.'],
['.', '.', '8', '.', '9', '1', '.', '6', '.'],
// ... Rest of the puzzle.
]
# Solve the Sudoku puzzle.
solution = solveSudoku(puzzle)
# Print the solved puzzle.
print(solution)
```
53AI,大模型落地应用首选服务商
定位:开箱即用的大模型落地应用平台
承诺:先做场景POC验证,看到效果再签署服务协议。零风险落地应用大模型,已交付160+中大型企业
如果你看见AI对商业世界的变革,欢迎来和我们一起探索~
2024-07-04
用coze零代码搭建一个知识库助手
2024-07-04
下一代 RAG 技术来了!微软正式开源 GraphRAG:大模型行业将迎来新的升级?
2024-07-04
什么是知识图谱?与大模型有什么关系
2024-07-04
检索生成(RAG) vs 长文本大模型:实际应用中如何选择?
2024-07-04
用腾讯星脉,给AI网络诊脉
2024-07-04
代码 | 使用本地大模型从文本中提取结构化信息
2024-07-04
Karpor 开源了!打造 AI 时代的 Kubernetes 可视化工具
2024-07-04
普林斯顿大学重磅 | 关键的AI Agent,你遇到过这4大Agent评估陷阱吗
2024-04-24
2024-05-14
2024-04-24
2024-04-23
2024-04-11
2024-04-26
2024-03-22
2024-03-29
2024-04-12
2024-04-25
2024-07-04
2024-07-04
2024-07-03
2024-07-02
2024-07-02
2024-07-01
2024-07-01
2024-07-01