当前位置:   article > 正文

mac体验ollama本地大模型_ollama mac

ollama mac

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;

  • 1
  • 2

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. 声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/529555

推荐阅读
相关标签