Git Product home page Git Product logo

gitblog's Introduction

Gitblog

My personal blog using issues and GitHub Actions referring to a wonderful gitblog repository

RSS Feed

最近更新

AI基础

Tips

工作流

计算机基础

gitblog's People

Contributors

dingyue772 avatar

Watchers

 avatar  avatar

gitblog's Issues

Github Issues博客之旅

感谢yihong老师开源的gitblog项目!

建立过程

开始于看到朋友在github仓库里利用issues写博客不要葱姜蒜的blog仓库,然后去google相关的教程,看到了大佬教程——使用Github Issues来写博客,接着就看到yihong老师的gitblog项目了,真的有被震撼到。在看的过程中我心里想的是“所有你想做的事情,世界上都有人在做了,并且做得很好!”,接着就下定决心要把我的gitblog搞起来

tips

同样的gitblog工作流建立参考使用Github Issues来写博客这个博客开源了
注意

  1. yihong老师的workflow文件夹中有两个action,generate_site.yml是和github pages关联的,可以查看内容后进行相应的配置再使用
  2. 一定要注意打开repository的settings中的actions的读写权限!!! (我在这里卡了很久很久

issues写博客的优势

  1. 提交issues自动更新仓库readme,并且根据label将issues展示在不同的二级标题下
  2. backup文件夹自动将所有issues以.md文件的形式保存起来
  3. 生成了feed.xml供订阅、并方便查看

ps:我用到的功能只是原gitblog项目的一部分,这里可以写的还有很多!

【RAG】了解RAG

RAG

image

InternLM+LangChain搭建RAG应用

工具包
开源词向量模型:Sentence Transformer(相对轻量、支持中文且效果较好)
NLTK相关资源

搭建向量知识库
知识库文件——FileLoader对象加载文件——分块、向量化、数据库存储

将LLM接入LangChain
基于本地部署的LLM自定义LLM类,即继承LangChain.llms.base.LLM 类
模型优化:使用混合模型——本地模型和云端模型API相结合

检索问答链构建
加载向量数据库——实例化自定义LLM和Prompt Template——构建检索问答链
检索优化:使用图检索、网页搜索进行优化

python环境相关

查看cuda版pytorch是否安装成功

import torch # 如果pytorch安装成功即可导入
print(torch.cuda.is_available()) # 查看CUDA是否可用
print(torch.cuda.device_count()) # 查看可用的CUDA数量
print(torch.version.cuda) # 查看CUDA的版本号

nvcc -V命令不可用
cudatoolkit没有在电脑环境中安装或者安装了但没有加入环境变量
参考检查pytorch是否安装成功、查看torch和cuda的版本

使用.env文件
import的是dotenv,但install的是python-dotenv

修改pip命令安装包的默认路径
参考python之修改pip默认install路径

【算法】快排、归并排序、二分法代码模板

快速排序模板

void quick_sort(int q[], int l, int r)
{
    if (l >= r) return;
    int i = l - 1, j = r + 1, x = q[l + r >>1];
    while (i < j)
    {
        do i ++; while (q[i] < x);
        do j --; while (q[j] > x);
        if (i < j) swap(q[i], q[j]);
    }
    quick_sort(q, l, j); quick_sort(q, j + 1, r);
}

归并排序模板

void merge_sort(int q[], int l, int r)
{
    if (l >= r) return;
    int mid = l + r >> 1;
    merge_sort(q, l, mid); merge_sort(q, mid + 1, r);
    int k = 0, i = l, j = mid + 1;
    while (i <= mid && j <= r)
    {
        if (q[i] <= q[j]) tmp[k ++] = q[i ++];
        else tmp[k ++] = q[j ++];
    }
    while(i <= mid) tmp[k ++] = q[i ++];
    while (j <= r) tmp[k ++] = q[j ++];
    for (int i = l, j = 0; i <= r; i++, j++) q[i] = tmp[j];
}

整数二分模板

// 找区间开始位置
int l = 0, r = n - 1;
while (l < r)
{
    int mid = l + r >> 1;
    if (q[mid] >= k) r = mid;
    else l = mid + 1;
}
if (q[l] != k) 
{
    printf("-1 -1\n");
    continue;
}
else printf("%d ", l);
// 找区间结束位置
l = 0, r = n - 1;
while (l < r)
{
    int mid = l + r + 1>> 1;
    if (q[mid] <= k) l = mid;
    else r = mid - 1;
}
printf("%d\n", r);

浮点数二分模板

double l = -1000, r = 1000;
double eps = 1e-8;
while (r - l > eps)
{
    double mid = (l + r) / 2;
    if (mid * mid * mid >= n) r = mid;
    else l = mid;
}
printf ("%.6lf", l);

【算法】回溯算法

理论基础

力扣题目分类展示
image

回溯法理解

所有使用回溯法解决的问题都可以抽象成树形结构
在集合中递归查找子集:集合大小即树的宽度,递归的深度即树的深度

回溯法模板
回溯三部曲:函数返回值及参数——函数终止条件——搜索的遍历过程

void backtracking(参数){
  if (终止条件){
    存放结果;
    return;
  }
  
  for (选择: 本层集合中元素(树中节点孩子数量就是集合大小)){
    处理节点;
    backtracking(路径, 选择列表); // 递归过程
    回溯, 撤销处理结果;
  }
}

image

93. 复原IP地址

力扣题目链接

给定一个只包含数字的字符串,复原它并返回所有可能的 IP 地址格式。
有效的 IP 地址 正好由四个整数(每个整数位于 0 到 255 之间组成,且不能含有前导 0),整数之间用 '.' 分隔。
例如:"0.1.2.201" 和 "192.168.1.1" 是 有效的 IP 地址,但是 "0.011.255.245"、"192.168.1.312" 和 "[email protected]" 是 无效的 IP 地址。

难点

  1. 字符串处理,在原有字符串里加入'.',s.insert()s.erase()的使用
  2. 判断子串是否满足IP地址的要求,不能前导0&范围在0~255

代码说明
函数定义

// 引入pointNum标识当前的逗点数量
void backtracking(string& s, int startIndex, int pointNum)

终止条件

if (pointNum == 3){
  if (isValid(s, startIndex, s.size()-1)) {
    result.push_back(s);
  }
  return;
}

单层递归

for (int i=startIndex; i<s.size(); i++) {
  if (isValid(s, startIndex, i)){
    s.insert(s.begin()+i+1, '.');
    pointNum++;
    backtracking(s, i+2, pointNum);
    pointNum--;
    s.erase(s.begin()+i+1);
  }
  else break;
}

IP地址判断:使用字符串计算出对应的IP分量的值进行判断

bool isValid(const string s, int start, int end)

参考资料

代码随想录

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.