mac体验ollama本地大模型

mac体验ollama本地大模型

type: Post
status: Published
date: 2024/03/25
slug: 240325-ollama
summary: m1 pro芯片+32g体验了五种大模型本地部署
tags: 工具, 折腾, 推荐
category: 技术分享

契机

⚙ 最近发现了meta发布了llama2模型,搜索一圈发现使用ollama部署特别的方便

基础配置

ollama

  • 直接去官网下载:https://ollama.com/
  • 命令行运行ollama -h查看命令集
  • 查看本地模型列表:ollama list
  • 下载并且运行模型:ollama run llama2:13b

Untitled

chatbox

  • gpt的client端,支持多种模型,包括ollama本地运行的模型
  • 地址:https://github.com/Bin-Huang/chatbox
  • 内置了许多的promot,比如软件工程师,翻译助手,小红书标题生成器
  • 支持为每一个会话指定特殊的模型

Untitled

模型对比

promot&question

promot:

你是一个高级软件工程师,你需要帮我解答各种技术难题、设计技术方案以及编写代码。你编写的代码必须可以正常运行,而且没有任何 Bug 和其他问题。如果你的回答中用代码,请用 markdown 代码块,并且在代码块中标明使用的编程语言。

question:

select * from t where c=5 for update;

but c not index,tell me the process of locking
and the time of release lock

openai:3.5

When you run a query like SELECT * FROM t WHERE c=5 FOR UPDATE; in MySQL on a column c that is not indexed, MySQL will perform a full table scan to find the rows that match the condition c=5. During this process, MySQL will acquire a shared lock on all the rows it reads to prevent other transactions from modifying them.

Here is the general process of locking and the time of releasing the lock:

  1. Shared (Read) Lock: MySQL will acquire a shared (read) lock on the rows that match the condition c=5. This lock allows other transactions to read the locked rows but prevents them from modifying them.
  2. Exclusive (Write) Lock: When you use FOR UPDATE in your query, MySQL will upgrade the shared lock to an exclusive (write) lock on the matched rows. This exclusive lock prevents other transactions from both reading and writing to the locked rows until the transaction is either committed or rolled back.
  3. Time of Releasing Lock: The lock acquired using FOR UPDATE will be released when the current transaction is either committed or rolled back. If the transaction is rolled back, the lock will be released immediately. If the transaction is committed, the exclusive locks will be released at the end of the transaction.

It’s important to note that locking behavior can vary depending on the isolation level of the transaction and the specific MySQL configuration settings. Additionally, using FOR UPDATE without an index on the column can lead to performance issues, especially on large tables, as it may result in full table scans and increased locking contention. Consider adding an index on column c if this query is frequently used for better performance.

mistral:7b

Based on your SQL query SELECT * FROM t WHERE c = 5 FOR UPDATE, it seems you are working with MySQL or a similar database management system. In this context, let’s discuss the process of obtaining and releasing locks in relation to this query.

When you execute the query SELECT * FROM t WHERE c = 5 FOR UPDATE, the database engine acquires a lock on the record(s) with column ‘c’ equal to 5, preventing other transactions from reading or updating those records until the current transaction is committed or rolled back. This process ensures data consistency and concurrency control.

The actual time of obtaining a lock depends on various factors such as network latency, server workload, and database configuration. Generally, it’s considered to be an instantaneous operation once the query execution reaches that point. However, keep in mind that the actual query processing time and network transfer time might add significant delay.

As for releasing the lock, it happens automatically when the current transaction is committed or rolled back. Once the transaction has been finalized, the database engine releases the locks on the corresponding records, making them available to other transactions again.

Here’s a simplified overview of the process:

  1. The query SELECT * FROM t WHERE c = 5 FOR UPDATE is executed.
  2. The database engine locates the record(s) with ‘c’ equal to 5 and acquires a lock on them.
  3. Once the query has finished processing those records, the transaction is committed or rolled back.
  4. If the transaction is committed, the locks are released and made available for other transactions.
  5. If the transaction is rolled back, the locks are also released but any changes made during the transaction are discarded.

llama2:4b

As a high-level software engineer, I’d be happy to help you with your question.

The query SELECT * FROM t WHERE c = 5 FOR UPDATE is a common mechanism for acquiring a row-level lock on a table t for the specified condition c = 5. When this query is executed, it will acquire an exclusive lock on the rows that match the condition, preventing any other concurrent updates or reads from accessing those rows until the lock is released.

The process of locking in this case involves the following steps:

  1. The query is executed and a lock is acquired on the relevant rows.
  2. The lock is held by the thread that executed the query, preventing any other threads from acquiring the same lock until it is released.
  3. The lock is released when the thread that executed the query completes its work and no longer needs the lock.
  4. Other threads can then acquire the lock and update or read the rows that were previously locked.

The time of release lock depends on various factors, including the operating system, hardware, and database configuration. In general, the lock is released when the thread that executed the query completes its work and no longer needs the lock. This can happen immediately after the query is executed, or it may take some time depending on the complexity of the task and the availability of resources.

In MySQL, the default isolation level is READ UNCOMMITTED, which means that locks are acquired using the FOR UPDATE clause. This allows other threads to read the rows while the first thread is updating them, but it does not guarantee that the second thread will see the updates made by the first thread before committing its changes.

If you want to acquire a lock on a specific row or set of rows without using the FOR UPDATE clause, you can use the LOCK TABLE statement in MySQL. This statement allows you to acquire an exclusive lock on a table for a specified period of time, preventing any other threads from accessing the table during that time.

Here is an example of how to use LOCK TABLE to acquire a lock on a specific row:

LOCK TABLE t FOR UPDATE OF c WHERE id = 5;

This will acquire an exclusive lock on the row with id = 5 in the table t, preventing any other threads from updating or reading that row until the lock is released.

Note that the LOCK TABLE statement can be used to acquire locks on multiple rows or tables, and it can also be used to acquire locks for longer periods of time than the default isolation level. However, it is important to use this statement judiciously and only when necessary to avoid contention and deadlocks.

starcoder2:15b

thank youusername_1: You are looking for a tool called VisualVM. It is part of the JDK and it allows you to connect to running java applications and view their memory consumption, threads etc.
Upvotes: 2 username_2: Have a look at the Eclipse Memory Analyzer (MAT) plugin (http://www.eclipse.org/mat/), there’s a video that shows how to use it: http://vimeo.com/7698540
Upvotes: 3 [selected_answer]username_3: I like JProfiler for this kind of thing. It has a very intuitive GUI and gives you the information you need in a way that makes sense.

http://www.ej-technologies.com/products/jprofiler/overview.html
Upvotes: 1 username_4: I have found JProfiler to be very useful for this. It has a nice UI and is easy to use.
Upvotes: 0

llama2:13b

Ah, I see! You’re trying to understand the locking mechanism in MySQL when using the FOR UPDATE clause. 🔒

When you execute a query like SELECT * FROM t WHERE c = 5 FOR UPDATE, MySQL acquires a lock on the rows that match the condition c = 5. This lock is called an “X-lock” or “exclusive lock,” which means that no other session can modify those rows until the current session releases the lock. 🔒

The locking mechanism in MySQL is based on the InnoDB storage engine, which uses a technique called “pessimistic locking.” This means that when a session wants to acquire a lock on a row, it first checks whether the row is already locked by another session. If the row is not locked, the session acquires the lock and prevents other sessions from acquiring the same lock until it releases the lock. 🔒

Now, to answer your questions:

  1. The process of locking: When a session executes a query with the FOR UPDATE clause, MySQL first checks whether the rows that match the condition are already locked by another session. If the rows are not locked, the current session acquires the lock and prevents other sessions from acquiring the same lock until it releases the lock.
  2. The time of release lock: When a session releases the lock on a row or set of rows, the lock is immediately released, and other sessions can then acquire the lock again. There is no specific “time of release” for locks in MySQL; instead, the lock is released as soon as the current session commits or rolls back the transaction. 🔒

I hope this helps clarify the locking mechanism in MySQL! Let me know if you have any other questions or concerns. 😊

总结

  • llama2效果不错,starcoder2不知所云
  • m1pro+32g环境下,4b模型在本地运行速度还可以,15b运行起来就特别吃力

写到最后

  • https://bothsavage.github.io/archive

Untitled

  • 24
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值