Tuesday, February 20, 2024

AI席卷全球龙头狂卷

最近几天,AI市场竞争日趋激烈。各大科技公司都在积极布局AI领域,推出各种新产品和新服务。特别时谷歌双子座(Google Gemini)和OpenAi 索拉(Sora),连我这样的小白也心潮起伏,决定恶补学习不能被时代浪潮抛弃啊:)



主要竞争者和热点

目前,AI市场的主要竞争者包括:

谷歌:谷歌在AI领域拥有强大的技术实力和丰富的资源,是AI市场的主要领导者。

微软:微软在AI领域也进行了大量投入,在一些细分领域具有领先优势。

亚马逊:亚马逊在AI领域主要集中在云服务方面,为企业提供AI解决方案。

Facebook:Facebook在AI领域主要集中在自然语言处理和计算机视觉方面。

百度:百度是中国领先的AI公司,在搜索、广告、自动驾驶等领域拥有广泛的应用。

阿里巴巴:阿里巴巴是中国另一家领先的AI公司,在电商、金融、物流等领域拥有广泛的应用。

竞争热点

自然语言处理:自然语言处理是AI领域的重要分支,主要研究人机之间的语言交互。

计算机视觉:计算机视觉是AI领域的重要分支,主要研究计算机对图像和视频的理解和处理。

机器学习:机器学习是AI的核心技术,主要研究计算机从数据中学习和自动改进的能力。

深度学习:深度学习是机器学习的一个重要分支,主要使用人工神经网络进行学习。

本人小白,一直在用Chatgpt帮助写程序,没有花钱也没有花精力,只是免费3.5;觉得写程序足够了,虽然它的知识库比较旧。今天加圈,希望向高手学习,我不由得抛出一块砖:),敬请指教。

下面主要就三家-聊天室(Chatgpt),谷歌双子座(Google Gemini)),微软副驾驶(Copilot)做个入门比较。

打开后我输入:

可否写一篇最新人工智能AI产品介绍比较,比如 coze,Taskade,copilot,Google Gemini, discord,midjourney, openai chatgpt,Sora等等

Chatgpt3.5回答:当我上次更新知识库时,即2022年1月,我并没有收集到关于所有这些产品的详细信息。然而,我可以根据我之前了解到的信息和推测为你提供一些一般性的介绍。请注意,这些信息可能已经过时,建议查阅最新的资料以获取准确和详细的信息。

因为这一原因,不再做比较,等搞好4.0再说。

Gemini和Copilot回答基本相似,都提及了刚刚推出的Sora和Gemini。Gemini还给了个比较表,而Copolit附上了信息来源地址。




接着提问:可否具体详细介绍并列出您的排行及推荐

Copilot排行推荐:Cozen,Taskade,Copilot,Gemini,Discord,Midjourney,Chatgpt, Sora
Gemini排行推荐:Gemini,Chatgpt,Copilot,Midjourney,Sora
Gemini把自己排第一,Copilot还挺谦虚,不过力压Gemini:)

接着做了一些生成图片和诗词指令,都还不错,Gemini似乎快一些,谷歌毕竟是老牌实力雄厚,听说这次全力以赴试图登上AI龙头位置。免费二年使用还是有很大吸引力,Copilot免费版本似乎也不错,交费三家差不多,20美元左右。

图像生成Copilot用的是Dall-E-OpenAI开发的一系列图像生成器,而GGemini使用Imagen生成图像,Imagen是Google AI于2023年5月推出的一个文本到图像扩散模型,可以生成逼真和富有创意的图像。

输入:请创作一首有关龙的传人之词,词牌为《西江月》
完全失败,三家全都是驴头不对马嘴,Coplit可能觉得不好意思,生成了不少图片。

再输入:您知道西江月多少字吗?
回答倒是正确50字上下阕,但就是写不出来,知识库还没有那么广,慢慢学习。


咋天首次用AI写了个春节报道文案,还是不错能省一半时间:)喜欢写作的我也许可以在这方面用用功,
听说不少写手写个大纲出文本,再用文本出图,发表在亚马逊自嗨平台(self publishing)。

最后谈谈现在流行的一个工程师,就是Prompt Engineer-指令工程师。

具体职责:

研究和理解各种生成式 AI 模型的特性和能力。
分析用户需求,并将其转化为清晰具体的指令 (prompt) 给 AI 模型。
设计、测试和优化不同的 prompt,以获得最佳的输出结果。
评估和分析 AI 模型的输出,并根据需要进行调整和改进。
根据特定领域和任务,开发和应用 prompt 工程技术。
与其他团队成员 (如数据科学家、工程师) 合作,构建和实现 AI 应用。

所需技能:

人工智能、自然语言处理 (NLP) 和机器学习方面的知识。
扎实的编程能力,熟悉各种编程语言和工具。
优秀的沟通和写作能力,能够清晰地表达自己的想法。
批判性思维和解决问题的能力,能够分析复杂的场景并找到解决方案。
对新技术和趋势的敏感性,并愿意不断学习和提升技能。

职业发展路径:

随着经验的积累,可以进一步提升技术水平,成为资深 prompt engineer。
可以专注于特定的领域,成为该领域的专家。
转向管理岗位,带领团队开发和实施 AI 应用。
创业,建立自己的 AI 公司。

薪资水平:

Prompt engineer 的薪资水平因地域、经验、公司规模等因素而异。在美国,prompt engineer 的平均年薪约为 150,000 美元。

是不是很诱人?!AI说我消减了不少工作,但我也创造了许多机会,所言虚否?!

Thursday, December 14, 2023

Bootstrap

Bootstrap, very cool, a popular front-end framework for building responsive and visually appealing websites.

d-inline is a utility class that sets the display property of an element to inline.

  • Margin and Padding:

    • m-1, m-2, ... m-5: Margin classes for spacing (1 to 5).
    • p-1, p-2, ... p-5: Padding classes for spacing (1 to 5).
    • mx-3: Horizontal margin.
    • px-3: Horizontal padding.
  • Text Alignment:

    • text-center: Center-align text.
    • text-right: Right-align text.
  • Background and Color:

    • bg-primary, bg-secondary, ...: Background color classes.
    • text-primary, text-secondary, ...: Text color classes.
  • Buttons:

    • btn, btn-primary, ...: Bootstrap button classes.
    • btn-outline-primary: Outline button with primary color.

Bootstrap, Here is the Documentation site for it: https://getbootstrap.com/docs/5.0/utilities/api/

WordPress - Useful Links

Very good WordPress tutorialshttps://www.wpbeginner.com/

Display posts plugin and tutorials:

https://displayposts.com/tutorials/

https://wordpress.org/plugins/display-post-types/


WordPress - PHP

Making new  menu and display location:

1. Code Snippets » Add Snippet 

<?php
    function wpb_top_right_menu() 
{
        register_nav_menu('top-right-menu',__( 'Top Right Menu' ));
}
add_action( 'init', 'wpb_top_right_menu' );?>

2. Appearance » Theme File Editor » Header(typically)

wp_nav_menu( array( 'theme_location'=>'top-right-menu', 'container_class'=>'top-right-class' ) );

WordPress - CSS

I am helping alumnus to build a WordPress website, quite interesting.

Additional CSS: good way to custom the style.

Remove the page title:

.bread_crumb

{ display: none; }

For custom top right menu:

div.top-right-class ul {

float:right;

    margin:20px 0px 20px 0px;

    list-style-type: none;

    list-style: none;

    list-style-image: none;

    text-align:right;

    display:inline-block;

}

div.top-right-class li {

    padding: 0px 20px 0px 0px;

    display: inline-block;

}  

div.top-right-class a { color:blue; }

Remove 1st letter drop cap:

.entry-content > p:first-of-type:first-letter{

font-size: 100%;

          line-height: 1; 

margin-right:-10px;

Display posts style:

.display-posts-listing .listing-item {    clear: both;  }

.display-posts-listing img {

    float: left;

    margin: 0 10px 10px 0;

}

Tuesday, November 28, 2023

MVC - C# Reference

? A question mark (?) is used to denote a nullable type. A nullable type can represent all the values of its underlying non-nullable value type plus an additional null value. This is particularly useful when dealing with value types, which cannot normally be assigned a null value. 

int? nullableInt = 42;  // Valid assignment

nullableInt = null;    // Valid assignment

DateTime? nullableDateTime = DateTime.Now;  // Valid assignment

nullableDateTime = null;                    // Valid assignment

?? The ?? operator, also known as the null-coalescing operator, is used for handling null values in a concise way. It provides a way to return a default value when the left-hand operand is null. 

string proName = pro?[0]?.Name ?? "Default Value";

The #pragma warning disable directive is used in C# to disable specific compiler warnings: #pragma warning disable CS8602

Target-typed new expressions are a feature introduced in C# 9.0. They allow you to omit the type in the new expression when the type can be inferred from the surrounding context. This helps reduce redundancy in your code and makes it more concise.        

// Without target-typed new expression

List<string> names = new List<string>();

// With target-typed new expression (C# 9.0 and later)

List<string> names = new(); 

The update-database command is part of the Entity Framework Migrations workflow and is crucial for keeping the database schema in sync with your code changes. It's a powerful tool that automates the process of evolving the database as your application evolves, making it easier to manage changes to your data model over time.

        Applying Database Migrations/Creating the Initial Database/Applying Subsequent     Migrations/Rolling Back Migrations

In Entity Framework, the DbContext class provides a set of methods to interact with the underlying database using LINQ queries. Here are some common methods associated with DbSet that allow you to perform various operations:

  1. Query Operations:

    • FirstOrDefault, SingleOrDefault: Retrieve the first or a single entity that satisfies a condition.
    • Where: Filter entities based on a condition.
    • OrderBy, OrderByDescending, ThenBy, ThenByDescending: Order entities based on one or more properties.
  2. Insert/Update Operations:

    • Add, AddRange: Add a new entity or a collection of entities to the context.
    • Attach: Attaches an entity or a disconnected graph of entities to the context.
    • Update: Marks an entity or entities as modified.
    • Remove, RemoveRange: Remove an entity or a collection of entities from the context.
  3. Save Changes:

    • SaveChanges, SaveChangesAsync: Persist changes made in the context to the underlying database.
  4. Bulk Operations:

    • Entity Framework Core (EF Core) has introduced extensions like BulkInsert, BulkUpdate, BulkDelete for handling bulk operations efficiently.
  5. Raw SQL Queries:

    • FromSqlRaw, FromSqlInterpolated: Execute raw SQL queries.



Friday, May 14, 2021

ORCL - Pivot

Sometime users request converting multiple rows to columns for same ID, like the following:

with l as

 (select '333' id, 'email1' email, 1 xsequence  from dual

  union  select '333' id, 'email2' email, 2 xsequence  from dual

  union  select '333' id, 'email3' email, 3 xsequence   from dual)

select * from l;

333 email1 1

333 email2 2

333 email3 3

Sometimes users are OK with comma concatenated like this (with listagg function):

333 email1,email2,email3 (one column)

And most time users want like this: 

333 email1 email2 email3 (3 columns)

So in order to get that, I used to do an old way: first rank() them and doing case then group max, like the following:

select n.id, max(email1) e1, max(email2) e2, max(email3) e3

  from (select m.id,  case  when rn = 1 then m.email  end email1,

               case when rn = 2 then m.email end email2,

               case when rn = 3 then m.email end email3

          from m) n  group by id

By using Pivot, it will cut the CASE and MAX, just like this:

select *  from m pivot (max(email) for rn in(1, 2, 3))

with l as
 (select '333' id, 'email1' email, 1 xsequence
    from dual
  union
  select '333' id, 'email2' email, 2 xsequence
    from dual
  union
  select '333' id, 'email3' email, 3 xsequence
    from dual),
m as
 (select distinct l.id, l.email,
                  rank() over(partition by l.id order by l.xsequence) rn  
    from l)
select *  from m pivot (max(email) for rn in(1, 2, 3))

If you want to select them for other joined query, you could set the column alias to get rid of the number(rn), since you can not pick/select the column started with numbers.

select *   from m
pivot (max(email) for rn in(1 as e1, 2 as e2, 3 as e3))

I made a video to show the process, thanks for watching!


You can online search for Pivot documentation and examples.

"Oracle 11g introduced the new PIVOT clause that allows you to write cross-tabulation queries which transpose rows into columns, aggregating data in the process of the transposing. As a result, the output of a pivot operation returns more columns and fewer rows than the starting data set.

In this syntax, following the PIVOT keyword are three clauses:

  • pivot_clause specifies the column(s) that you want to aggregate. The pivot_clause performs an implicitly GROUP BY based on all columns which are not specified in the clause, along with values provided by the pivot_in_clause.
  • pivot_for_clause specifies the column that you want to group or pivot.
  • pivot_in_clause defines a filter for column(s) in the pivot_for_clause. The aggregation for each value in the pivot_in_clause will be rotated into a separate column."